A general purpose function class which can refer to any static method, member method, functor, or lambda function. More...
#include <Caller.h>
Public Member Functions | |
Caller () | |
Default constructor, refers to no function. | |
Caller (const Caller &other) | |
Copy constructor. | |
template<class C > | |
Caller (C *object, Ret(C::*func)(Params...)) | |
Construct a Caller to a member function of a specific object. | |
template<class C > | |
Caller (C &object, Ret(C::*func)(Params...)) | |
Construct a Caller to a member function of a specific object. | |
template<class C , class... OneFewerParams> | |
Caller (Ret(C::*func)(OneFewerParams...)) | |
Construct a Caller to a member function, where the inserted first parameter is a reference to the object. More... | |
template<class Functor > | |
Caller (Functor func) | |
Construct a Caller to any general functor. More... | |
virtual | ~Caller () |
Destructor. | |
Caller & | operator= (const Caller< Ret, Params... > &other) |
Assign a Caller of identical type. | |
virtual Ret | operator() (Params... params) const |
Call the referenced function. | |
bool | IsSet () |
True if a function was set. | |
template<class TupleType > | |
Ret | Use (TupleType tup) |
Call the referenced function with the parameters given as RC::Tuple tup. | |
template<class... Args> | |
auto | Bind (Args... args) -> decltype(std::bind(*this, args...)) |
Return a functor with arguments bound using syntax identical to std::bind. More... | |
A general purpose function class which can refer to any static method, member method, functor, or lambda function.
Template parameters are specified as the return type followed by a list of the argument types. If access is attempted on an undefined Caller, ErrorMsgNull is thrown. If a member method Caller is constructed with the object as the first parameter, then the call is assigned to that object, which can be used for passing handlers. The convenience functions MakeCaller and MakeFunctor can be used for automatic type inference. Strict compile time type-checking is performed upon assignment or construction. To explicitly wrap with loose type-checking, use MakeFunctor on a Caller.
|
inline |
Construct a Caller to a member function, where the inserted first parameter is a reference to the object.
Usage example: class A { void F(int x) {} }; Caller<void, A&, int> c(&A::F); c(5);
|
inline |
|
inline |
Return a functor with arguments bound using syntax identical to std::bind.
The return type of this is an unspecified functor, but it can be wrapped in a MakeFunctor with the corresponding types.