...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 Polymorphic Function 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.
template< typename Function, class Sequence > typename result_of::invoke_function_object<Function, Sequence>::type invoke_function_object(Function f, Sequence & s); template< typename Function, class Sequence > typename result_of::invoke_function_object<Function, Sequence const>::type invoke_function_object(Function f, Sequence const & s);
Parameter |
Requirement |
Description |
---|---|---|
f |
Model of Polymorphic Function Object |
The function object to call. |
s |
Model of Forward Sequence |
The arguments. |
invoke_function_object(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_function_object.hpp>
struct sub { template <typename Sig> struct result; template <class Self, typename T> struct result< Self(T,T) > { typedef typename remove_reference<T>::type type; }; template<typename T> T operator()(T lhs, T rhs) const { return lhs - rhs; } }; void try_it() { sub f; assert(f(2,1) == invoke_function_object(f,make_vector(2,1))); }