...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.
#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 |
---|---|---|
|
||
|
||
|
||
|
A unary function object or function pointer. |
|
|
A binary function object or function pointer. |
transform_view
).
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
Semantics of an expression is defined only where it differs from, or is not defined in the implemented models.
Expression |
Semantics |
---|---|
|
Creates a unary |
|
Creates a binary |
|
Copy constructs a |
|
Assigns to a |
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;