| Home | Libraries | People | FAQ | More

### list

#### Description

`list` is a Forward Sequence of heterogenous typed data built on top of `cons`. It is more efficient than `vector` when the target sequence is constructed piecemeal (a data at a time). The runtime cost of access to each element is peculiarly constant (see Recursive Inlined Functions).

#### Header

    #include <boost/fusion/container/list.hpp>
    #include <boost/fusion/include/list.hpp>
    #include <boost/fusion/container/list/list_fwd.hpp>
    #include <boost/fusion/include/list_fwd.hpp>

#### Synopsis

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

The variadic class interface accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults to `10`. Example:

    list<int, char, double>

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

    #define FUSION_MAX_LIST_SIZE 20

#### Template parameters

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

#### Model of

- Forward Sequence

Notation

`L`

  A `list` type

`l`

  An instance of `list`

`e0`...`en`

  Heterogeneous values

`s`

  A Forward Sequence

`N`

  An MPL Integral Constant

#### Expression Semantics

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

Expression | Semantics
--- | ---
`L()` | Creates a list with default constructed elements.
`L(e0, e1,... en)` | Creates a list with elements `e0`...`en`.
`L(s)` | Copy constructs a list from a Forward Sequence, `s`.
`l = s` | Assigns to a list, `l`, from a Forward Sequence, `s`.
``at`<N>(l)` | The Nth element from the beginning of the sequence; see `at`.

#### Example

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