Title
Can't make neither head nor tail of the description of operator<=>(tuple, tuple)
Status
new
Section
[tuple.rel]
Submitter
Corentin Jabot

Created on 2022-06-28.00:00:00 last changed 28 months ago

Messages

Date: 2022-07-08.20:04:38

Proposed resolution:

This wording is relative to N4910.

  1. Modify [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 first i for which the result of that expression does not compare equal to 0. If no such i exists, strong_ordering::equal.Performs a lexicographical comparison between t and u. For any two zero-length tuples t and u, t <=> u 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 tuple r is a tuple containing all but the first element of r.

    -?- Remarks: The elementary 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 to 0.

    -5- [Note 1: 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 required to determine the result of the comparison. — end note]

Date: 2022-07-15.00:00:00

[ 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.

Date: 2022-06-28.00:00:00

The specification of operator<=>(tuple, tuple) ([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.

The remark is copied from the similar wording of operator==

History
Date User Action Args
2022-07-08 20:04:38adminsetmessages: + msg12566
2022-07-03 12:20:01adminsetmessages: + msg12546
2022-06-28 00:00:00admincreate