Include the TR1 header <tuple> to define a template tuple whose instances hold objects of varying types.
namespace std {
namespace tr1 {
// TEMPLATE CLASSES
template<class... Types>
class tuple;
template<int Idx, class Ty>
class tuple_element; // not defined
template<int Idx, class... Types>
class tuple_element<Idx, tuple<Types...>>;
template<class Ty>
class tuple_size; // not defined
template<class... Types>
class tuple_size<tuple<Types...>>;
// TEMPLATE Functions
template<int Idx, class Types>
typename tuple_element <Idx, tuple<Types...>>::type&
get(tuple<Types...&> tpl);
template<int Idx, class Types>
typename tuple_element <Idx, tuple<Types...>>::type&
get(const tuple<Types...&> tpl);
template<class... Types>
tuple<Types2...>
make_tuple(Types...);
template<class... Types>
tuple<Types&...>
Tie(Types&...);
// TEMPLATE COMPARISON OPERATORS
template<class... Types1, class... Types2>
bool operator==(const tuple<Types1...>& tpl1,
const tuple<Types2...>& tpl2;
template<class... Types1, class... Types2>
bool operator!=(const tuple<Types1...>& tpl1,
const tuple<Types2...>& tpl2;
template<class... Types1, class... Types2>
bool operator<(const tuple<Types1...>& tpl1,
const tuple<Types2...>& tpl2;
template<class... Types1, class... Types2>
bool operator<=(const tuple<Types1...>& tpl1,
const tuple<Types2...>& tpl2;
template<class... Types1, class... Types2>
bool operator>(const tuple<Types1...>& tpl1,
const tuple<Types2...>& tpl2;
template<class... Types1, class... Types2>
bool operator>=(const tuple<Types1...>& tpl1,
const tuple<Types2...>& tpl2;
//CONST OBJECTS
const T1 ignore;
} // namespace tr1
} // namespace std
The template class describes an object that stores zero or more objects of types specified by Types. The extent of a tuple instance is the number N of its template arguments. The index of the template argument Ti (counting from zero) and of the corresponding stored value of that type is i.
template<class... Types>
class tuple {
public:
tuple();
explicit tuple(const Types&...);
tuple(const tuple& right);
template <class... Types2>
tuple(const tuple<Types2...>& right);
template <class U1, class U2>
tuple(const pair<U1, U2>& right);
tuple(tuple&& right)
template <class... Types2>
tuple(tuple<Types2...>&& right);
template <class U1, class U2>
tuple(pair<U1, U2>&& right);
tuple& operator=(const tuple& right);
template <class... Types2>
tuple& operator=(const tuple<Types2...>& right);
template <class U1, class U2>
tuple& operator=(const pair<U1, U2>& right);
tuple& operator=(tuple&& right);
template <class... Types2>
tuple& operator=(tuple<Types2...>&& right);
template <class U1, class U2>
tuple& operator=(pair<U1, U2>&& right);
};
tuple();
explicit tuple(const Types&...);
tuple(const tuple& right);
template <class... Types2>
tuple(const tuple<Types2...>& right);
template <class U1, class U2>
tuple(const pair<U1, U2>& right);
tuple(tuple&& right)
template <class... Types2>
tuple(tuple<Types2...>&& right);
template <class U1, class U2>
tuple(pair<U1, U2>&& right);
The first constructor constructs an object whose elements are default constructed. The second constructor constructs an object whose elements are copy constructed from the argument list. The third and fourth constructors construct an object whose elements are copy constructed from the corresponding element of right. The fifth constructor constructs an object whose element at index 0 is copy constructed from right.first and whose element at index 1 is copy constructed from right.second.
tuple& operator=(const tuple& right);
template <class... Types2>
tuple& operator=(const tuple<Types2...>& right);
template <class U1, class U2>
tuple& operator=(const pair<U1, U2>& right);
tuple& operator=(tuple&& right);
template <class... Types2>
tuple& operator=(tuple<Types2...>&& right);
template <class U1, class U2>
tuple& operator=(pair<U1, U2>&& right);
The first two member operators assign the elements of right to the corresponding elements of *this. The third member operator assigns right.first to the element at index 0 of *this and right.second to the element at index 1. All three member operators return *this.
template<int Idx, class Ty>
class tuple_element; // not defined
template<int Idx, class... Types>
class tuple_element<Idx, tuple<Types...>>;
The template class has a member type Type that is a synonym for the type at index Idx of the type Tuple<Types...>.
template<class Ty>
class tuple_size; // not defined
template<class... Types>
class tuple_size<tuple<Types...>>;
The template class has a member const int value whose value is the extent of the type Tuple<Types...>.
template<int Idx, class... Types>
typename tuple_element <Idx, tuple<Types...>>::type&
get(tuple<Types...&> tpl);
template<int Idx, class Types>
typename tuple_element <Idx, tuple<Types...>>::type&
get(const tuple<Types...&> tpl);
The template functions return a reference to the value at index Idx in the tuple object tpl. If the corresponding type Ti in Types is a reference type, both functions return Ti; otherwise the first function returns Ti& and the second function returns const Ti&.
template<class... Types>
tuple<Types2...>
make_tuple(Types...);
The template function returns a tuple object constructed from the argument list, where each type T2i in Types2 is the same as Ti in Types, except where Ti is reference_wrapper<X>, in which case T2i is X.
template<class... Types1, class... Types2>
bool operator==(const tuple<Types1...>& tpl1,
const tuple<Types2...>& tpl2;
The function returns true only when both tuples are empty, or when get<0>(tpl1) == get<0>(tpl2) &&... for all corresponding elements.
template<class... Types1, class... Types2>
bool operator!=(const tuple<Types1...>& tpl1,
const tuple<Types2...>& tpl2;
The function returns !(tpl1 == tpl2).
template<class... Types1, class... Types2>
bool operator<(const tuple<Types1...>& tpl1,
const tuple<Types2...>& tpl2;
The function returns true only when both tuples are not empty and get<0>(tpl1) < get<0>(tpl2) || !(get<0>(tpl2) < get<0>(tpl1)) &&... for all corresponding elements.
template<class... Types1, class... Types2>
bool operator<=(const tuple<Types1...>& tpl1,
const tuple<Types2...>& tpl2;
The function returns !(tpl2 < tpl1).
template<class... Types1, class... Types2>
bool operator>(const tuple<Types1...>& tpl1,
const tuple<Types2...>& tpl2;
The function returns tpl2 < tpl1.
template<class... Types1, class... Types2>
bool operator>=(const tuple<Types1...>& tpl1,
const tuple<Types2...>& tpl2;
The function returns !(tpl1 < tpl2).
template<class... Types>
tuple<Types&...>
Tie(Types&...);
The template function returns a tuple object constructed from the argument list, where each element is a reference. Note that a reference to ignore can be assigned anything and will do nothing.
Certain materials included or referred to in this document are copyright P.J. Plauger and/or Dinkumware, Ltd. or are based on materials that are copyright P.J. Plauger and/or Dinkumware, Ltd.
Notwithstanding the meta-data for this document, copyright information for this document is as follows:
Copyright © IBM Corp. 1999, 2010. & Copyright © P.J. Plauger and/or Dinkumware, Ltd. 1992-2006.