Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
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.

Example:

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

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(d)) [11].

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');


[11] see Ref utility for details about ref


PrevUpHomeNext