...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
template< typename Sequence , typename Op > struct transform { typedef unspecified type; };
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.
#include "boost/mpl/transform.hpp"
Parameter | Requirement | Description |
---|---|---|
Sequence | A model of Extensible Sequence | The original sequence. |
Op | An unary [Lambda Expression] | A transformation. |
Expression | Expression type | Precondition | Semantics | Postcondition |
---|---|---|---|---|
typedef transform<Sequence,Op>::type s; | A model of Extensible Sequence | size<s>::type::value == size<Sequence>::type::value . |
Linear. The operation Op
is applied exactly size<Sequence>::type::value
times.
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));
Algorithms, replace
, replace_if
, transform