This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
operator<=>(tuple, tuple)
Section: 22.4.9 [tuple.rel] Status: New Submitter: Corentin Jabot Opened: 2022-06-28 Last modified: 2022-07-08
Priority: 4
View other active issues in [tuple.rel].
View all other issues in [tuple.rel].
View all issues with New status.
Discussion:
The specification of operator<=>(tuple, tuple)
(22.4.9 [tuple.rel]) is described in
terms of imaginary tuples (ttail
, utail
, rtail
)
which is a bit confusing. Indeed, It is not clear that these imaginary tuples need to respect the order of
elements of u
and t
, nor whether the value category of the elements in these imaginary
tuples can or should be conserved. It is possible to reformulate and simplify that description so that
no imaginary tuple is involved.
operator==
[2022-07-08; Reflector poll]
Set priority to 4 after reflector poll.
Some votes for NAD and preference for the current wording, adding "in order"
to clarify the order of elements in rtail
.
Proposed resolution:
This wording is relative to N4910.
Modify 22.4.9 [tuple.rel] as indicated:
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);-4-
EffectsReturns:synth-three-way(get<i>(t), get<i>(u))
for the firsti
for which the result of that expression does not compare equal to0
. If no suchi
exists,strong_ordering::equal
.Performs a lexicographical comparison betweent
andu
. For any two zero-length tuplest
andu
,t <=> u
returnsstrong_ordering::equal
. Otherwise, equivalent to:if (auto c = synth-three-way(get<0>(t), get<0>(u)); c != 0) return c; return ttail <=> utail;-?- Remarks: The elementary
wherertail
for some tupler
is a tuple containing all but the first element ofr
.synth-three-way(get<i>(t), get<i>(u))
expressions are evaluated in order from the zeroth index upwards. No element accesses are performed after the first invocation that results in a value that does not compare equal to0
.-5- [Note 1: The above definition does not requirettail
(orutail
) to be constructed. It might not even be possible, ast
andu
are not required to be copy constructible. Also, all comparison operator functions are short circuited; they do not perform element accesses beyond what is required to determine the result of the comparison. — end note]