<p>gives the type of the <code>N</code>th element in the tuple type <code>T</code>. If <code>T</code> is const, the resulting type is const qualified as well.
Both tuple template and the cons templates provide the typedefs <code>head_type</code> and <code>tail_type</code>.
The <code>head_type</code> typedef gives the type of the first element of the tuple (or the cons list).
The
<code>tail_type</code> typedef gives the remaining cons list after removing the first element.
The head element is stored in the member variable <code>head</code> and the tail list in the member variable <code>tail</code>.
Cons lists provide the member function <code>get_head()</code> for getting a reference to the head of a cons list, and <code>get_tail()</code> for getting a reference to the tail.
There are const and non-const versions of both functions.
</p>
<p>
Note that in a one element tuple, <code>tail_type</code> equals <code>null_type</code> and the <code>get_tail()</code> function returns an object of type <code>null_type</code>.
</p>
<p>
The empty tuple (<code>null_type</code>) has no head or tail, hence the <code>get_head</code> and <code>get_tail</code> functions are not provided.
</p>
<p>
Treating tuples as cons lists gives a convenient means to define generic functions to manipulate tuples. For example, the following pair of function templates assign 0 to each element of a tuple (obviously, the assignments must be valid operations for the element types):
<p>The traits template for the head parameter selects correct parameter types for different kinds of element types (for reference elements the parameter type equals the element type, for non-reference types the parameter type is a reference to const non-volatile element type).
<li><code>access_traits<T>::non_const_type</code> maps <code>T</code> to the return type of the non-const access functions (nonmember and member <code>get</code> functions, and the <code>get_head</code> function).</li>
<p>The element types of the tuples that are created with the <code>make_tuple</code> functions are computed with the type function <code>make_tuple_traits</code>.
The type function call <code>make_tuple_traits<T>::type</code> implements the following type mapping:</p>
<p>Objects of type <code>reference_wrapper</code> are created with the <code>ref</code> and <code>cref</code> functions (see <Ahref="tuple_users_guide.html#make_tuple">The <code>make_tuple</code> function</A>.)
<p>Reference wrappers were originally part of the tuple library, but they are now a general utility of boost.
The <code>reference_wrapper</code> template and the <code>ref</code> and <code>cref</code> functions are defined in a separate file <code>ref.hpp</code> in the main boost include directory; and directly in the <code>boost</code> namespace.