Files
cppdraft_translate/cppdraft/tuple/helper.md
2025-10-25 03:02:53 +03:00

4.6 KiB
Raw Blame History

[tuple.helper]

22 General utilities library [utilities]

22.4 Tuples [tuple]

22.4.7 Tuple helper classes [tuple.helper]

🔗

template<class T> struct tuple_size;

1

#

Except where specified otherwise, all specializations of tuple_size meet theCpp17UnaryTypeTrait requirements ([meta.rqmts]) with a base characteristic of integral_constant<size_t, N> for some N.

🔗

template<class... Types> struct tuple_size<tuple<Types...>> : integral_constant<size_t, sizeof...(Types)> { };

🔗

template<size_t I, class... Types> struct tuple_element<I, tuple<Types...>> { using type = TI; };

2

#

Mandates: I < sizeof...(Types).

3

#

Type: TI is the type of the Ith element of Types, where indexing is zero-based.

🔗

template<class T> struct tuple_size<const T>;

4

#

Let TS denote tuple_size 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 ofintegral_constant<size_t, TS::value>

Otherwise, it has no member value.

5

#

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 1:

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]

6

#

In addition to being available via inclusion of the header, the template is available when any of the headers,, or are included.

🔗

template<size_t I, class T> struct tuple_element<I, const T>;

7

#

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.

8

#

In addition to being available via inclusion of the header, the template is available when any of the headers,, or are included.