32 #include <type_traits> 50 template<
typename R,
typename B,
typename C,
typename... Args>
53 static_assert (std::is_base_of<B, C> {},
"Base class where the member pointer belongs must be convertible to the binded object's class.");
54 return [fn, c] (Args... args) {
return (c->*fn) (args...); };
57 template<
typename R,
typename B,
typename C,
typename... Args>
58 auto BindMemFn (R (B::*fn) (Args...)
const,
const C *c)
60 static_assert (std::is_base_of<B, C> {},
"Base class where the member pointer belongs must be convertible to the binded object's class.");
61 return [fn, c] (Args... args) {
return (c->*fn) (args...); };
67 template<
typename From>
68 std::enable_if_t<!std::is_base_of<To, std::decay_t<From>>::value, To>
operator() (From&& from)
const 70 return To { std::forward<From> (from) };
73 template<
typename From>
74 std::enable_if_t<std::is_base_of<To, std::decay_t<From>>::value, To>
operator() (From&& from)
const 86 template<
typename From,
typename = std::enable_if_t<std::is_base_of_v<To, std::decay_t<From>>>>
87 To* operator() (From *from)
const
auto BindMemFn(R(B::*fn)(Args...), C *c)
Binds an instance of an object to its member function.
std::enable_if_t<!std::is_base_of< To, std::decay_t< From > >::value, To > operator()(From &&from) const