The TR1 technical report describes extensions to the C++ standard library.
Many of these extensions will be considered for the next
iteration of the C++ standard. TR1 describes a tuple type, and
support for treating `std::pair` as a type of tuple.
Fusion provides full support for the __tr1__tuple__ interface, and the extended
uses of `std::pair` described in the TR1 document.
[section Class template tuple]
Fusion's implementation of the __tr1__tuple__ is also a fusion __forward_sequence__.
As such the fusion tuple type provides a lot of functionality beyond that required by TR1.
Currently tuple is basically a synonym for __vector__, although this may be changed
in future releases of fusion.
[heading Synopsis]
template<
typename T1 = __unspecified__,
typename T2 = __unspecified__,
...
typename TN = __unspecified__>
class tuple;
/tuple.hpp>
[section Construction]
[heading Description]
The __tr1__tuple__ type provides a default constructor, a constructor that takes initializers for all of its elements, a copy constructor, and a converting copy constructor. The details of the various constructors are described in this section.
[heading Specification]
[variablelist Notation
[[`T1 ... TN`, `U1 ... UN`][Tuple element types]]
[[`P1 ... PN`] [Parameter types]]
[[`Ti`, `Ui`] [The type of the `i`th element of a tuple]]
[[`Pi`] [The type of the `i`th parameter]]
]
tuple();
[*Requirements]: Each `Ti` is default constructable.
[*Semantics]: Default initializes each element of the tuple.
tuple(P1,P2,...,PN);
[*Requirements]: Each `Pi` is `Ti` if `Ti` is a reference type, `const Ti&` otherwise.
[*Semantics]: Copy initializes each element with the corresponding parameter.
tuple(const tuple& t);
[*Requirements]: Each `Ti` should be copy constructable.
[*Semantics]: Copy constructs each element of `*this` with the corresponding element of `t`.
[*Requirements]: Each `Ti` shall be constructible from the corresponding `Ui`.
[*Semantics]: Constructs each element of `*this` with the corresponding element of `t`.
[endsect]
[section Tuple creation functions]
[heading Description]
TR1 describes 2 utility functions for creating __tr1__tuple__s. `make_tuple` builds a tuple out of it's argument list, and `tie` builds a tuple of references to it's arguments. The details of these creation functions are described in this section.
[*Returns]: tuple<T1&, T2&, ..., TN&>(t1, t2, ..., tN). When argument `ti` is `ignore`, assigning any value to the corresponding tuple element has has no effect.
[endsect]
[section Tuple helper classes]
[heading Description]
The __tr1__tuple__ provides 2 helper traits, for compile time access to the tuple size, and the element types.
[heading Specification]
tuple_size<T>::value
[*Requires]: `T` is any fusion sequence type, including `tuple`.
[*Type]: __mpl_integral_constant__
[*Value]: The number of elements in the sequence. Equivalent to `__result_of_size__<T>::type`.
tuple_element<I, T>::type
[*Requires]: `T` is any fusion sequence type, including `tuple`. `0 <= I < N` or the program is ill formed.
[*Value]: The type of the `I`th element of `T`. Equivalent to `__result_of_value_at__<I,T>::type`.
[endsect]
[section Element access]
[heading Description]
The __tr1__tuple__ provides the `get` function to provide access to it's elements by zero based numeric index.
[heading Specification]
template<int I, T>
RJ get(T& t);
[*Requires]: `0 < I <= N`. The program is ill formed if `I` is out of bounds.
`T` is any fusion sequence type, including `tuple`.
[*Return type]: `RJ` is equivalent to `__result_of_at_c__<I,T>::type`.
[*Returns]: A reference to the `I`th element of `T`.
template<int I, typename T>
PJ get(T const& t);
[*Requires]: `0 < I <= N`. The program is ill formed if `I` is out of bounds.
`T` is any fusion sequence type, including `tuple`.
[*Return type]: `PJ` is equivalent to `__result_of_at_c__<I,T>::type`.
[*Returns]: A const reference to the `I`th element of `T`.
[endsect]
[section Relational operators]
[heading Description]
The __tr1__tuple__ provides the standard boolean relational operators.
[heading Specification]
[variablelist Notation
[[`T1 ... TN`, `U1 ... UN`][Tuple element types]]
[[`P1 ... PN`] [Parameter types]]
[[`Ti`, `Ui`] [The type of the `i`th element of a tuple]]