20 General utilities library [utilities]

20.5 Tuples [tuple]

20.5.6 Tuple helper classes [tuple.helper]

template<class T> struct tuple_size;
All specializations of tuple_­size meet the Cpp17UnaryTypeTrait requirements ([meta.rqmts]) with a base characteristic of integral_­constant<size_­t, N> for some N.
template<class... Types> struct tuple_size<tuple<Types...>> : public integral_constant<size_t, sizeof...(Types)> { };
template<size_t I, class... Types> struct tuple_element<I, tuple<Types...>> { using type = TI; };
Mandates: .
Type: TI is the type of the element of Types, where indexing is zero-based.
template<class T> struct tuple_size<const T>;
Let TS denote tuple_­size<T> of the cv-unqualified type T.
If the expression TS​::​value is well-formed when treated as an unevaluated operand, then each specialization of the template meets the Cpp17UnaryTypeTrait requirements ([meta.rqmts]) with a base characteristic of
integral_constant<size_t, TS::value>
Otherwise, it has no member value.
Access checking is performed as if in a context unrelated to TS and T.
Only the validity of the immediate context of the expression is considered.
Note
:
The compilation of the expression can result in side effects such as the instantiation of class template specializations and function template specializations, the generation of implicitly-defined functions, and so on.
Such side effects are not in the โ€œimmediate contextโ€ and can result in the program being ill-formed.
โ€” end note
 ]
In addition to being available via inclusion of the <tuple> header, the template is available when any of the headers <array> ([array.syn]), <ranges> ([ranges.syn]), or <utility> ([utility.syn]) are included.
template<size_t I, class T> struct tuple_element<I, const T>;
Let TE denote tuple_­element_­t<I, T> of the cv-unqualified type T.
Then each specialization of the template meets the Cpp17TransformationTrait requirements ([meta.rqmts]) with a member typedef type that names the type add_­const_­t<TE>.
In addition to being available via inclusion of the <tuple> header, the template is available when any of the headers <array> ([array.syn]), <ranges> ([ranges.syn]), or <utility> ([utility.syn]) are included.