...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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. The transform_view inherits the traversal characteristics (see Sequence Traversal Concept) of its underlying sequence or sequences.
#include <boost/fusion/view/transform_view.hpp> #include <boost/fusion/include/transform_view.hpp>
Unary Version
template <typename Sequence, typename F1> struct transform_view;
Binary Version
template <typename Sequence1, typename Sequence2, typename F2> struct transform_view;
Parameter |
Description |
Default |
---|---|---|
Sequence |
|
|
Sequence1 |
|
|
Sequence2 |
|
|
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. |
|
Notation
A transform_view type
A binary transform_view type
A unary transform_view type
An instance of F1
An instance of F2
An instance of Sequence
An instance of Sequence1
An instance of Sequence2
Instances of transform_view
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 or sequences.
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. |
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;