| Home | Libraries | People | FAQ | More

##### invoke_function_object

###### Description

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.

Constructors can be called applying Boost.Functional/Factory Library.

###### 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_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.

###### Header

    #include <boost/fusion/functional/invocation/invoke_function_object.hpp>

###### Example

    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)));
    }

###### See also

- `invoke`
- `invoke_procedure`
- `result_of::invoke_function_object`
- `fused_function_object`
- `make_fused_function_object`