Boost
boost
arrow_drop_down
Boost news learn community libraries releases
Join

PrevUpHomeNext

The unary version of transform_view presents a view of its underlying sequence given a unary function object or function pointer. The binary version of transform_view presents a view of 2 underlying sequences, given a binary function object or function pointer.

Header
#include <boost/fusion/view/transform_view.hpp>
#include <boost/fusion/include/transform_view.hpp>
Synopsis

Unary Version

template <typename Sequence, typename F1>
struct transform_view;

Binary Version

template <typename Sequence1, typename Sequence2, typename F2>
struct transform_view;
Template parameters

Parameter

Description

Default

Sequence

A Forward Sequence

Sequence1

A Forward Sequence

Sequence2

A Forward Sequence

F1

A unary function object or function pointer. boost::result_of<F1(E)>::type is the return type of an instance of F1 when called with a value of each element type E in the input sequence.

F2

A binary function object or function pointer. boost::result_of<F2(E1, E2)>::type is the return type of an instance of F2 when called with a value of each corresponding pair of element type E1 and E2 in the input sequences.

Model of

Notation

TV

A transform_view type

BTV

A binary transform_view type

UTV

A unary transform_view type

f1

An instance of F1

f2

An instance of F2

s

An instance of Sequence

s1

An instance of Sequence1

s2

An instance of Sequence2

tv, tv2

Instances of transform_view

Expression Semantics

Semantics of an expression is defined only where it differs from, or is not defined in the implemented models.

Expression

Semantics

UTV(s, f1)

Creates a unary transform_view given sequence, s and unary function object or function pointer, f1.

BTV(s1, s2, f2)

Creates a binary transform_view given sequences, s1 and s2 and binary function object or function pointer, f2.

TV(tv)

Copy constructs a transform_view from another transform_view, tv.

tv = tv2

Assigns to a transform_view, tv, from another transform_view, tv2.

Example
struct square
{
    template<typename Sig>
    struct result;

    template<typename U>
    struct result<square(U)>
    : remove_reference<U>
    {};

    template <typename T>
    T operator()(T x) const
    {
        return x * x;
    }
};

typedef vector<int, short, double> vector_type;
vector_type vec(2, 5, 3.3);

transform_view<vector_type, square> transform(vec, square());
std::cout << transform << std::endl;

PrevUpHomeNext