11 #include <type_traits>
29 template<
typename R,
typename B,
typename C,
typename... Args>
30 auto BindMemFn (R (B::*fn) (Args...), C *c)
32 static_assert (std::is_base_of<B, C> {},
"Base class where the member pointer belongs must be convertible to the binded object's class.");
33 return [fn, c] (Args... args) {
return (c->*fn) (args...); };
36 template<
typename R,
typename B,
typename C,
typename... Args>
37 auto BindMemFn (R (B::*fn) (Args...)
const,
const C *c)
39 static_assert (std::is_base_of<B, C> {},
"Base class where the member pointer belongs must be convertible to the binded object's class.");
40 return [fn, c] (Args... args) {
return (c->*fn) (args...); };
46 template<
typename From>
47 std::enable_if_t<!std::is_base_of<To, std::decay_t<From>>::value, To>
operator() (From&& from)
const
49 return To { std::forward<From> (from) };
52 template<
typename From>
53 std::enable_if_t<std::is_base_of<To, std::decay_t<From>>::value, To>
operator() (From&& from)
const
65 template<
typename From,
typename = std::enable_if_t<std::is_base_of_v<To, std::decay_t<From>>>>
66 To* operator() (From *from)
const