...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
nview
presents a view which
iterates over a given Sequence in
a specified order. An nview
is constructed from an arbitrary Sequence
and a list of indices specifying the elements to iterate over.
#include <boost/fusion/view/nview.hpp> #include <boost/fusion/include/nview.hpp>
template <typename Sequence, typename Indices> struct nview; template <typename Sequence, int I1, int I2 = -1, ...> typename result_of::nview<Sequence, I1, I2, ...>::type as_nview(Sequence& s);
Parameter |
Description |
Default |
---|---|---|
|
An arbitrary Fusion Forward Sequence |
|
|
A |
|
|
A list of integers specifying the required iteration order. |
|
Notation
NV
A nview
type
s
An instance of Sequences
nv1
, nv2
Instances of NV
Semantics of an expression is defined only where it differs from, or is not defined in Random Access Sequence.
Expression |
Semantics |
---|---|
|
Creates an |
|
Copy constructs an |
|
Assigns to an |
The nview
internally stores
a Fusion vector
of references to the elements of the original Fusion Sequence
typedef vector
<int, char, double> vec;
typedef mpl::vector_c<int, 2, 1, 0, 2, 0> indices;
vec v1(1, 'c', 2.0);
std::cout << nview<vec, indices>(v1) << std::endl; // (2.0 c 1 2.0 1)
std::cout << as_nview<2, 1, 1, 0>(v1) << std::endl; // (2.0 c c 1)