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

PrevUpHomeNext

fused

Description

An unary Polymorphic Function Object adapter template for Deferred Callable Object target functions. 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 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 class members, 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).

Header
#include <boost/fusion/functional/adapter/fused.hpp>
Synopsis
template <typename Function>
class fused;
Template parameters

Parameter

Description

Default

Function

A Deferred Callable Object

Model of

Notation

R

A possibly const qualified Deferred 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>

Expression Semantics

Expression

Semantics

fused<R>(r)

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

fused<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.

Example
fused< std::plus<long> > f;
assert(f(make_vector(1,2l)) == 3l);
See also

PrevUpHomeNext