[tuple.rel] # 22 General utilities library [[utilities]](./#utilities) ## 22.4 Tuples [[tuple]](tuple#rel) ### 22.4.9 Relational operators [tuple.rel] [🔗](#lib:operator==,tuple) `template constexpr bool operator==(const tuple& t, const tuple& u); template constexpr bool operator==(const tuple& t, const UTuple& u); ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2957) For the first overload let UTuple be tuple[.](#1.sentence-1) [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2960) *Constraints*: For all i, where 0 ≤ i < sizeof...(TTypes),get(t) == get(u) is a valid expression anddecltype(get(t) == get(u)) models [*boolean-testable*](concept.booleantestable#concept:boolean-testable "18.5.2 Boolean testability [concept.booleantestable]")[.](#2.sentence-1) sizeof...(TTypes) equalstuple_size_v[.](#2.sentence-2) [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2969) *Returns*: true if get(t) == get(u) for alli, otherwise false[.](#3.sentence-1) [*Note [1](#note-1)*: If sizeof...(TTypes) equals zero, returns true[.](#3.sentence-2) — *end note*] [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2977) *Remarks*: - [(4.1)](#4.1) The elementary comparisons are performed in order from the zeroth index upwards[.](#4.1.sentence-1) No comparisons or element accesses are performed after the first equality comparison that evaluates tofalse[.](#4.1.sentence-2) - [(4.2)](#4.2) The second overload is to be found via argument-dependent lookup ([[basic.lookup.argdep]](basic.lookup.argdep "6.5.4 Argument-dependent name lookup")) only[.](#4.2.sentence-1) [🔗](#lib:operator%3c=%3e,tuple) `template constexpr common_comparison_category_t...> operator<=>(const tuple& t, const tuple& u); template constexpr common_comparison_category_t...> operator<=>(const tuple& t, const UTuple& u); ` [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3001) For the second overload, Elems denotes the pack of typestuple_element_t<0, UTuple>,tuple_element_t<1, UTuple>, …,tuple_element_t - 1, UTuple>[.](#5.sentence-1) [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3007) *Effects*: Performs a lexicographical comparison between t and u[.](#6.sentence-1) If sizeof...(TTypes) equals zero, returns strong_ordering​::​equal[.](#6.sentence-2) Otherwise, equivalent to:if (auto c = *synth-three-way*(get<0>(t), get<0>(u)); c != 0) return c;return ttail <=> utail; where rtail for some r is a tuple containing all but the first element of r[.](#6.sentence-3) [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3020) *Remarks*: The second overload is to be found via argument-dependent lookup ([[basic.lookup.argdep]](basic.lookup.argdep "6.5.4 Argument-dependent name lookup")) only[.](#7.sentence-1) [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L3025) [*Note [2](#note-2)*: The above definition does not require ttail (or utail) to be constructed[.](#8.sentence-1) It might not even be possible, as t and u are not required to be copy constructible[.](#8.sentence-2) Also, all comparison operator functions are short circuited; they do not perform element accesses beyond what is needed to determine the result of the comparison[.](#8.sentence-3) — *end note*]