Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
invoke_function_object
Description

Calls a Polymorphic Function Object with the arguments from a Sequence.

The corresponding metafunction, result_of::invoke_function_object, does not define a type member, if the nested result class template of the target function object is empty.

The first template parameter can be specialized explicitly to avoid copying and/or to control the const qualification of a function object.

Synopsis
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);
Parameters
Parameter Requirement Description
f Model of Polymorphic Function Object The function object to call.
s Model of Forward Sequence The arguments.
Expression Semantics
invoke_procedure(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.

Header
#include <boost/fusion/functional/invocation/invoke_function_object.hpp>
Example
struct sub
{
    template<typename T, typename _>
    struct result
    {
        typedef T 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)));
}
See also
Copyright © 2001-2007 Joel de Guzman, Dan Marsden, Tobias Schwinger

PrevUpHomeNext