...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Calls a Deferred Callable Object with the arguments from a Sequence.
The first template parameter can be specialized explicitly to avoid copying and/or to control the const qualification of a function object.
If the target function is a pointer to a class members, the corresponding object can be specified as a reference, pointer, or smart pointer. In case of the latter, a freestanding get_pointer function must be defined (Boost provides this function for std::auto_ptr and boost::shared_ptr).
template< typename Function, class Sequence > typename result_of::invoke<Function, Sequence>::type invoke(Function f, Sequence & s); template< typename Function, class Sequence > typename result_of::invoke<Function, Sequence const>::type invoke(Function f, Sequence const & s);
Parameter |
Requirement |
Description |
---|---|---|
f |
The function to call. |
|
s |
The arguments. |
invoke(f,s);
Return type: Return type of f when invoked with the elements in s as its arguments.
Semantics: Invokes f with the elements in s as arguments and returns the result of the call expression.
/functional/invocation/invoke.hpp>
std::plus<int> add; assert(invoke(add,make_vector(1,1)) == 2);