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

This is an old version of boost. Click here for the latest version's documentation home page.

[Home]transform

Synopsis

template<
      typename Sequence
    , typename Op
    >
struct transform
{
    typedef unspecified type;
};

Description

Performs a transformation on the sequence. The algorithm returns a new sequence produced by applying the unary metafunction Op to every element in the [begin<Sequence>::type, end<Sequence>::type) range. The result sequence preserves all the functional and performance characteristics of the original Sequence, including its size, but not identity.

Definition

#include "boost/mpl/transform.hpp"

Parameters

 Parameter  Requirement  Description  
SequenceA model of Extensible SequenceThe original sequence.
OpAn unary [Lambda Expression]A transformation.

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
typedef transform<Sequence,Op>::type s;A model of Extensible Sequencesize<s>::type::value == size<Sequence>::type::value.

Complexity

Linear. The operation Op is applied exactly size<Sequence>::type::value times.

Example

typedef list<char,short,int,long,float,double> types;
typedef list<char*,short*,int*,long*,float*,double*> pointers;
typedef transform< types,boost::add_pointer<_1> >::type result;
BOOST_STATIC_ASSERT((equal<result,pointers>::value));

See also

Algorithms, replace, replace_if, transform


Table of Contents
Last edited July 17, 2002 5:47 am