[tuple.helper] # 22 General utilities library [[utilities]](./#utilities) ## 22.4 Tuples [[tuple]](tuple#helper) ### 22.4.7 Tuple helper classes [tuple.helper] [🔗](#lib:tuple_size,in_general) `template struct tuple_size; ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2761) Except where specified otherwise, all specializations of tuple_size meet the[*Cpp17UnaryTypeTrait*](meta.rqmts#:Cpp17UnaryTypeTrait "21.3.2 Requirements [meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2 Requirements")) with a base characteristic of integral_constant for some N[.](#1.sentence-1) [🔗](#lib:tuple_size) `template struct tuple_size> : integral_constant { }; ` [🔗](#lib:tuple_element) `template struct tuple_element> { using type = TI; }; ` [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2784) *Mandates*: I < sizeof...(Types)[.](#2.sentence-1) [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2788) *Type*: TI is the type of the Ith element of Types, where indexing is zero-based[.](#3.sentence-1) [🔗](#lib:tuple_size_) `template struct tuple_size; ` [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2801) Let TS denote tuple_size of the cv-unqualified type T[.](#4.sentence-1) If the expression TS​::​value is well-formed when treated as an [unevaluated operand](expr.context#def:unevaluated_operand "7.2.3 Context dependence [expr.context]"), then each specialization of the template meets the [*Cpp17UnaryTypeTrait*](meta.rqmts#:Cpp17UnaryTypeTrait "21.3.2 Requirements [meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2 Requirements")) with a base characteristic ofintegral_constant Otherwise, it has no member value[.](#4.sentence-3) [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2812) Access checking is performed as if in a context unrelated to TS and T[.](#5.sentence-1) Only the validity of the immediate context of the expression is considered[.](#5.sentence-2) [*Note [1](#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[.](#5.sentence-3) Such side effects are not in the “immediate context” and can result in the program being ill-formed[.](#5.sentence-4) — *end note*] [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2824) In addition to being available via inclusion of the [](tuple.syn#header:%3ctuple%3e "22.4.2 Header synopsis [tuple.syn]") header, the template is available when any of the headers[](array.syn#header:%3carray%3e "23.3.2 Header synopsis [array.syn]"),[](ranges.syn#header:%3cranges%3e "25.2 Header synopsis [ranges.syn]"), or[](utility.syn#header:%3cutility%3e "22.2.1 Header synopsis [utility.syn]") are included[.](#6.sentence-1) [🔗](#lib:tuple_element_) `template struct tuple_element; ` [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2840) Let TE denote tuple_element_t of the cv-unqualified type T[.](#7.sentence-1) Then each specialization of the template meets the [*Cpp17TransformationTrait*](meta.rqmts#:Cpp17TransformationTrait "21.3.2 Requirements [meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2 Requirements")) with a member typedef type that names the type add_const_t[.](#7.sentence-2) [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2845) In addition to being available via inclusion of the [](tuple.syn#header:%3ctuple%3e "22.4.2 Header synopsis [tuple.syn]") header, the template is available when any of the headers[](array.syn#header:%3carray%3e "23.3.2 Header synopsis [array.syn]"),[](ranges.syn#header:%3cranges%3e "25.2 Header synopsis [ranges.syn]"), or[](utility.syn#header:%3cutility%3e "22.2.1 Header synopsis [utility.syn]") are included[.](#8.sentence-1)