| Home | Libraries | People | FAQ | More

### vector

##### Description

`vector` is a Random Access Sequence of heterogeneous typed data structured as a simple `struct` where each element is held as a member variable. `vector` is the simplest of the Fusion sequence container (a vector with N elements is just a struct with N members), and in many cases the most efficient.

##### Header

    #include <boost/fusion/container/vector.hpp>
    #include <boost/fusion/include/vector.hpp>
    #include <boost/fusion/container/vector/vector_fwd.hpp>
    #include <boost/fusion/include/vector_fwd.hpp>

    // numbered forms
    #include <boost/fusion/container/vector/vector10.hpp>
    #include <boost/fusion/include/vector10.hpp>
    #include <boost/fusion/container/vector/vector20.hpp>
    #include <boost/fusion/include/vector20.hpp>
    #include <boost/fusion/container/vector/vector30.hpp>
    #include <boost/fusion/include/vector30.hpp>
    #include <boost/fusion/container/vector/vector40.hpp>
    #include <boost/fusion/include/vector40.hpp>
    #include <boost/fusion/container/vector/vector50.hpp>
    #include <boost/fusion/include/vector50.hpp>

##### Synopsis

Numbered forms

    struct vector0;

    template <typename T0>
    struct vector1;

    template <typename T0, typename T1>
    struct vector2;

    template <typename T0, typename T1, typename T2>
    struct vector3;

    ...

    template <typename T0, typename T1, typename T2..., typename TN>
    struct vectorN;

| Important
Numbered forms will be deprecated in C++11 and it will be provided via aliasing templates. It means that your partial specialization might be compile error. You can detect whether it is aliasing templates or not, using `BOOST_FUSION_HAS_VARIADIC_VECTOR`.

Variadic form

    template <
        typename T0 = unspecified
      , typename T1 = unspecified
      , typename T2 = unspecified
        ...
      , typename TN = unspecified
    >
    struct vector;

The numbered form accepts the exact number of elements. Example:

    vector3<int, char, double>

For C++11 compilers, the variadic function interface has no upper bound.

For C++03 compilers, the The variadic form accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that defaults to `10`. Example:

    vector<int, char, double>

You may define the preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the default. Example:

    #define FUSION_MAX_VECTOR_SIZE 20

##### Template parameters

Parameter | Description | Default
--- | --- | ---
`T0`...`TN` | Element types | unspecified

##### Model of

- Random Access Sequence

Notation

`v`

  Instance of `vector`

`V`

  A `vector` type

`e0`...`en`

  Heterogeneous values

`s`

  A Forward Sequence

##### Expression Semantics

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

Expression | Semantics
--- | ---
`V()` | Creates a vector with default constructed elements.
`V(e0, e1,... en)` | Creates a vector with elements `e0`...`en`.
`V(s)` | Copy constructs a vector from a Forward Sequence, `s`.
`v = s` | Assigns to a vector, `v`, from a Forward Sequence, `s`.

##### Example

    vector<int, float> v(12, 5.5f);
    std::cout << at_c<0>(v) << std::endl;
    std::cout << at_c<1>(v) << std::endl;