class Cgu::Callback::FunctorArg< FreeArg >
Functor class holding a Callback::CallbackArg object.
- See also
This class wraps a CallbackArg object. The callback object is kept by SharedPtr so the functor can be copied and offers automatic lifetime management of the wrapped callback object, as well as providing an operator()() function. Ownership is taken of the CallbackArg object passed to the constructor taking a CallbackArg pointer, so that constructor should be treated like a shared pointer constructor - only pass a newly allocated object to it (or copy construct it or assign to it from another existing FunctorArg object.). The template type is the type of the unbound argument or container of unbound argument types, if any. Callback::FunctorArg<void> is typedef'ed to Callback::Functor.
The constructor taking a Callback::CallbackArg pointer is not marked explicit, so the results of Callback::make() can be passed directly to a function taking a Callback::FunctorArg argument, and implicit conversion will take place.
For a class object my_obj of type MyClass, with a method void MyClass::my_method(int, const char*), usage for a fully bound functor would be:
Or for a partially bound functor:
int arg = 1;
Callback/CallbackArg classes do not provide for a return value. If a result is wanted, users should pass an unbound argument by reference or pointer (or pointer to pointer).
For further background, including about the Callback::make() and Callback::make_ref() functions, and the use of the Cgu::TypeTuple struct for calls with two or three unbound arguments, read this: Callback