4.1 KiB
[tuple.rel]
22 General utilities library [utilities]
22.4 Tuples [tuple]
22.4.9 Relational operators [tuple.rel]
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.3 Concept tuple-like [tuple.like]") UTuple> constexpr bool operator==(const tuple<TTypes...>& t, const UTuple& u);
For the first overload let UTuple be tuple<UTypes...>.
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.
sizeof...(TTypes) equalstuple_size_v.
Returns: true if get(t) == get(u) for alli, otherwise false.
[Note 1:
If sizeof...(TTypes) equals zero, returns true.
â end note]
Remarks:
-
The elementary comparisons are performed in order from the zeroth index upwards. No comparisons or element accesses are performed after the first equality comparison that evaluates tofalse.
-
The second overload is to be found via argument-dependent lookup ([basic.lookup.argdep]) only.
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.3 Concept tuple-like [tuple.like]") UTuple> constexpr common_comparison_category_t<synth-three-way-result<TTypes, Elems>...> operator<=>(const tuple<TTypes...>& t, const UTuple& u);
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 - 1, UTuple>.
Effects: Performs a lexicographical comparison between t and u.
If sizeof...(TTypes) equals zero, returns strong_ordering::equal.
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.
Remarks: The second overload is to be found via argument-dependent lookup ([basic.lookup.argdep]) only.
[Note 2:
The above definition does not require ttail (or utail) to be constructed.
It might not even be possible, as t and u are not required to be copy constructible.
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.
â end note]