Callable Object and Callable Type
A callable type is:
- pointer to function
- pointer to a member function
- pointer to a member data [ see mem_fn ]
- object that can stand on the left of the function call operator
- object implementing operator()
- object implementing conversion operator returning a pointer to function
A callable object is an object of a callable type.
result_of class template:
The result_of meta-function (class template) provides a uniform way to get the type of the return value of a callable type.
The metafunction takes the type of the callable object followed by the list of its argument types. Example:
template <class Ct, class Arg>
void result_of_example(Ct fun, Arg arg)
// the object can be called fun(arg)
typedef typename std::tr1::result_of< Ct(Arg)>::type ret;
int operator()(int i) const
note: for the result_of to work properly on user-defined callable objects, the member typedef result_type must be defined as the return type of the function call operator().