| Home | Libraries | People | FAQ | More

### nview

##### Description

`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 indicies specifying the elements to iterate over.

##### Header

    #include <boost/fusion/view/nview.hpp>
    #include <boost/fusion/include/nview.hpp>

##### Synopsis

    template <typename Sequence, typename Indicies>
    struct nview;

    template <typename Sequence, int I1, int I2 = -1, ...>
    typename result_of::nview<Sequence, I1, I2, ...>::type
    as_nview(Sequence& s);

##### Template parameters

Parameter | Description | Default
--- | --- | ---
`Sequence` | An arbitrary Fusion Forward Sequence |
`Indicies` | A `mpl::vector_c<int, ...>` holding the indicies defining the required iteration order. |
`I1`, `I2`, `I3`... | A list of integers specifying the required iteration order. | `INT_MAX` for `I2`, `I3`...

##### Model of

- Random Access Sequence (see Sequence Traversal Concept)

Notation

`NV`

  A `nview` type

`s`

  An instance of `Sequences`

`nv1`, `nv2`

  Instances of `NV`

##### Expression Semantics

Semantics of an expression is defined only where it differs from, or is not defined in Random Access Sequence.

Expression | Semantics
--- | ---
`NV(s)` | Creates an `nview` given a sequence and a list of indicies.
`NV(nv1)` | Copy constructs an `nview` from another `nview`, `nv1`.
`nv1 = nv2` | Assigns to an `nview`, `nv1`, from another `nview`, `nv2`.

The `nview` internally stores a Fusion `vector` of references to the elements of the original Fusion Sequence

##### Example

    typedef vector<int, char, double> vec;
    typedef mpl::vector_c<int, 2, 1, 0, 2, 0> indicies;

    vec v1(1, 'c', 2.0);

    std::cout << nview<vec, indicies>(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)