Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
make_fused_function_object
Description

Creates a fused_function_object adapter for a given Deferred Callable Object. The usual element conversion is applied to the target function.

Synopsis
template <typename F>
inline typename make_fused_function_object<F>::type
make_fused_function_object(F const & f);
Parameters

Parameter

Requirement

Description

f

Model of Polymorphic Function Object

The function to transform.

Expression Semantics
make_fused_function_object(f);

Return type: A specialization of fused_function_object.

Semantics: Returns a fused_function_object adapter for f.

Header
#include <boost/fusion/functional/generation/make_fused_function_object.hpp>
#include <boost/fusion/include/make_fused_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()
{
    vector<int,float> a(2,2.0f);
    vector<int,float> b(1,1.5f);
    vector<int,float> c(1,0.5f);
    assert(c == transform(zip(a,b), make_fused_function_object(sub())));
}
See also

PrevUpHomeNext