| Home | Libraries | People | FAQ | More

##### Tiers

Tiers are sequences, where all elements are non-const reference types. They are constructed with a call to a couple of tie function templates. The succeeding sections document the various tier flavors.

- `list_tie`
- `vector_tie`
- `map_tie`

Example:

    int i; char c; double d;
      ...
    vector_tie(i, c, a);

The `vector_tie` function creates a `vector` of type ``vector`<int&, char&, double&>`. The same result could be achieved with the call `make_vector`(`ref`(i), `ref`(c), `ref`(a)) [10] .

A tie can be used to 'unpack' another tuple into variables. E.g.:

    int i; char c; double d;
    vector_tie(i, c, d) = make_vector(1,'a', 5.5);
    std::cout << i << " " <<  c << " " << d;

This code prints 1 a 5.5 to the standard output stream. A sequence unpacking operation like this is found for example in ML and Python. It is convenient when calling functions which return sequences.

###### Ignore

There is also an object called ignore which allows you to ignore an element assigned by a sequence. The idea is that a function may return a sequence, only part of which you are interested in. For example:

    char c;
    vector_tie(ignore, c) = make_vector(1, 'a');

[10] see Boost.Ref for details about `ref`