<<<<<<< .working ======= >>>>>>> .merge-right.r57125
Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
<<<<<<< .working

fused_function_object

Description
=======
Description
>>>>>>> .merge-right.r57125

An unary Polymorphic Function Object adapter template for a Polymorphic Function Object target function. It takes a Forward Sequence that contains the arguments for the target function.

The type of the target function is allowed to be const qualified or a reference. Const qualification is preserved and propagated appropriately (in other words, only const versions of operator() can be used for an target function object that is const or, if the target function object is held by value, the adapter is const).

<<<<<<< .working
Header
=======
Header
>>>>>>> .merge-right.r57125
#include <boost/fusion/functional/adapter/fused_function_object.hpp>
<<<<<<< .working
Synopsis
=======
Synopsis
>>>>>>> .merge-right.r57125
template <class Function>
class fused_function_object;
<<<<<<< .working
Template =======
Template >>>>>>> .merge-right.r57125 parameters

Parameter

Description

Default

Function

Polymorphic Function Object type

<<<<<<< .working
Model =======
Model >>>>>>> .merge-right.r57125 of

Notation

R

A possibly const qualified Polymorphic Function Object type or reference type thereof

r

An object convertible to R

s

A Sequence of arguments that are accepted by r

f

An instance of fused<R>

<<<<<<< .working
Expression =======
Expression >>>>>>> .merge-right.r57125 Semantics

Expression

Semantics

fused_function_object<R>(r)

Creates a fused function as described above, initializes the target function with r.

fused_function_object<R>()

Creates a fused function as described above, attempts to use R's default constructor.

f(s)

Calls r with the elements in s as its arguments.

<<<<<<< .working
Example
=======
Example
>>>>>>> .merge-right.r57125
template<class SeqOfSeqs, class Func>
typename result_of::transform< zip_view<SeqOfSeqs> const,
    fused_function_object<Func const &> >::type
n_ary_transform(SeqOfSeqs const & s, Func const & f)
{
    return transform(zip_view<SeqOfSeqs>(s),
        fused_function_object<Func const &>(f));
}

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 == n_ary_transform(vector_tie(a,b), sub()));
}
<<<<<<< .working
See =======
See >>>>>>> .merge-right.r57125 also

PrevUpHomeNext