Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

transform_view

transform_view presents a transformed view of its underlying sequence given a unary Polymorphic Function Object. The transform_view inherits the traversal characteristics (see Sequence Traversal Concept) of its underlying sequence.

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

Unary Version

template <typename Sequence, typename F>
struct transform_view;

Binary Version

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

Parameter

Description

Default

Sequence

A Forward Sequence

Sequence1

A Forward Sequence

Sequence2

A Forward Sequence

F

A Polymorphic Function Object

Model of

Notation

TV
A transform_view type
BTV
A binary transform_view type
UTV
A unary transform_view type
f
An instance of F
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 Forward Sequence, Bidirectional Sequence or Random Access Sequence depending on the traversal characteristics (see Sequence Traversal Concept) of its underlying sequence.

Expression

Semantics

UTV(s, f)

Creates a unary transform_view given sequence, s and unary Polymorphic Function Object, f.

BTV(s1, s2, f)

Creates a binary transform_view given sequences, s1 and s2 and unary Polymorphic Function Object, f.

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 T>
    struct result
    {
        typedef T type;
    };

    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;
Copyright © 2001-2007 Joel de Guzman, Dan Marsden, Tobias Schwinger

PrevUpHomeNext