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

PrevUpHomeNext
<<<<<<< .working

fused_procedure

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

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

The result is discared and the adapter's return type is void.

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 a target function object that is const or, if the target function object is held by value, the adapter is const - these semantics have nothing to do with the const qualification of a member function, which is referring to the type of object pointed to by this which is specified with the first element in the sequence passed to the adapter).

If the target function is a pointer to a members function, the corresponding object can be specified as a reference, pointer, or smart pointer. In case of the latter, a freestanding get_pointer function must be defined (Boost provides this function for std::auto_ptr and boost::shared_ptr).

The target function must not be a pointer to a member object (dereferencing such a pointer without returning anything does not make sense, so this case is not implemented).

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

Parameter

Description

Default

Function

Callable Object type

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

Notation

R

A possibly const qualified Callable 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_procedure<R>(r)

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

fused_procedure<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 SequenceOfSequences, class Func>
void n_ary_for_each(SequenceOfSequences const & s, Func const & f)
{
    for_each(zip_view<SequenceOfSequences>(s),
        fused_procedure<Func const &>(f));
}

void try_it()
{
    vector<int,float> a(2,2.0f);
    vector<int,float> b(1,1.5f);
    using namespace boost::lambda;
    n_ary_for_each(vector_tie(a,b), _1 -= _2);
    assert(a == make_vector(1,0.5f));
}
<<<<<<< .working
See =======
See >>>>>>> .merge-right.r57125 also

PrevUpHomeNext