<<<<<<< .working ======= <<<<<<< .working >>>>>>> .merge-right.r57125 ======= >>>>>>> .merge-right.r58299
Boost C++ Libraries Home Libraries People FAQ More

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, a);

<<<<<<< .working 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)) [9] ======= 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)) [9] >>>>>>> .merge-right.r57125 .

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.

<<<<<<< .working <<<<<<< .working <<<<<<< .working <<<<<<< .working <<<<<<< .working <<<<<<< .working Ignore ======= ======= ======= ======= ======= ======= >>>>>>> .merge-right.r58559 >>>>>>> .merge-right.r58549 >>>>>>> .merge-right.r58299 >>>>>>> .merge-right.r57337 >>>>>>> .merge-right.r57242 Ignore >>>>>>> .merge-right.r57125

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


<<<<<<< .working <<<<<<< .working <<<<<<< .working <<<<<<< .working <<<<<<< .working <<<<<<< .working

[9] =======

[9] =======

[9] =======

[9] =======

[9] =======

[9] =======

[9] >>>>>>> .merge-right.r58559 >>>>>>> .merge-right.r58549 >>>>>>> .merge-right.r58299 >>>>>>> .merge-right.r57337 >>>>>>> .merge-right.r57242 >>>>>>> .merge-right.r57125 see Boost.Ref for details about ref


PrevUpHomeNext