This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

110
cppdraft/tuple/rel.md Normal file
View File

@@ -0,0 +1,110 @@
[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<class... TTypes, class... UTypes>
constexpr bool operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
template<class... TTypes, [tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
constexpr bool operator==(const tuple<TTypes...>& 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<UTypes...>[.](#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<i>(t) == get<i>(u) is a valid expression anddecltype(get<i>(t) == get<i>(u)) models [*boolean-testable*](concept.booleantestable#concept:boolean-testable "18.5.2Boolean testability[concept.booleantestable]")[.](#2.sentence-1)
sizeof...(TTypes) equalstuple_size_v<UTuple>[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2969)
*Returns*: true if get<i>(t) == get<i>(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.4Argument-dependent name lookup")) only[.](#4.2.sentence-1)
[🔗](#lib:operator%3c=%3e,tuple)
`template<class... TTypes, class... UTypes>
constexpr common_comparison_category_t<synth-three-way-result<TTypes, UTypes>...>
operator<=>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
template<class... TTypes, [tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple>
constexpr common_comparison_category_t<synth-three-way-result<TTypes, Elems>...>
operator<=>(const tuple<TTypes...>& 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<tuple_size_v<UTuple> - 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.4Argument-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*]