20 #include <type_traits> 22 #define FUNCTOR_TYPEDEF(name, rettype, ...) \ 23 typedef Functor<rettype, ## __VA_ARGS__> name 25 #define FUNCTOR_DECLARE(name, rettype, ...) \ 26 Functor<rettype, ## __VA_ARGS__> name 28 #define FUNCTOR_BIND(obj, func, rettype, ...) \ 29 Functor<rettype, ## __VA_ARGS__>::bind<std::remove_reference<decltype(*obj)>::type, func>(obj) 31 #define FUNCTOR_BIND_MEMBER(func, rettype, ...) \ 32 Functor<rettype, ## __VA_ARGS__>::bind<std::remove_reference<decltype(*this)>::type, func>(this) 34 template <
class RetType,
class... Args>
46 : Functor(nullptr, nullptr) { }
49 : Functor(nullptr, nullptr) { }
65 explicit operator bool()
const 70 template<
class T, RetType (T::*method)(Args...)>
73 return { obj, method_wrapper<T, method> };
80 template<
class T, RetType (T::*method)(Args...)>
83 T *t =
static_cast<T*
>(obj);
84 return (t->*method)(args...);
static constexpr Functor bind(T *obj)
static RetType method_wrapper(void *obj, Args... args)
RetType(* _method)(void *obj, Args...)
RetType operator()(Args... args) const
bool operator==(const Functor< RetType, Args... > &rhs)
constexpr Functor(void *obj, RetType(*method)(void *obj, Args...))
constexpr Functor(decltype(nullptr))