Title
Define totally_ordered/_with in terms of partially-ordered-with
Status
c++20
Section
[concept.totallyordered]
Submitter
Great Britain

Created on 2019-11-08.00:00:00 last changed 45 months ago

Messages

Date: 2019-11-08.15:56:47

Proposed resolution:

This wording is relative to N4835.

  1. Change [concept.totallyordered] as follows:

    template<class T>
      concept totally_ordered =
        equality_comparable<T> && partially-ordered-with<T, T>;
        requires(const remove_reference_t<T>& a,
                 const remove_reference_t<T>& b) {
          { a <  b } -> boolean;
          { a >  b } -> boolean;
          { a <= b } -> boolean;
          { a >= b } -> boolean;
        };
    

    -1- For some type T, let a, b, and c be lvalues of type const remove_reference_t<T>. T models totally_ordered only if

    (1.1) — Exactly one of bool(a < b), bool(a > b), or bool(a == b) is true.

    (1.2) — If bool(a < b) and bool(b < c), then bool(a < c).

    (1.3) — bool(a > b) == bool(b < a).

    (1.4) — bool(a <= b) == !bool(b < a).

    (1.5) — bool(a >= b) == !bool(a < b).

    template<class T, class U>
      concept totally_ordered_with =
        totally_ordered<T> && totally_ordered<U> &&
        common_reference_with<const remove_reference_t<T>&, const remove_reference_t<U>&> &&
        totally_ordered<
          common_reference_t<
            const remove_reference_t<T>&,
            const remove_reference_t<U>&>> &&
          equality_comparable_with<T, U> &&
          partially-ordered-with<T, U>;
          requires(const remove_reference_t<T>& t,
                   const remove_reference_t<U>& u) {
            { t <  u } -> boolean;
            { t >  u } -> boolean;
            { t <= u } -> boolean;
            { t >= u } -> boolean;
            { u <  t } -> boolean;
            { u >  t } -> boolean;
            { u <= t } -> boolean;
            { u >= t } -> boolean;
          };
    

    […]

Date: 2019-11-08.15:56:47

[ 2019-11 Status to Ready Friday afternoon LWG in Belfast ]

Date: 2019-11-08.00:00:00

Addresses GB 202

Define totally_ordered[_with] in terms of partially-ordered-with. This will simplify the definition of both concepts (particularly totally_ordered_with), and make them in-line with equality_comparable[_with]. Now that we've defined partially-ordered-with for [cmp.concept], we should consider utilising it in as many locations as possible.

Proposed change:

template<class T>
  concept totally_ordered =
    equality_comparable<T> &&
    partially-ordered-with<T, T>;

template<class T, class U>
  concept totally_ordered_with =
    totally_ordered<T> &&
    totally_ordered<U> &&
    common_reference_with<
      const remove_reference_t<T>&,
      const remove_reference_t<U>&> &&
    totally_ordered<
      common_reference_t<
        const remove_reference_t<T>&,
        const remove_reference_t<U>&>> &&
    equality_comparable_with<T, U> &&
    partially-ordered-with<T, U>;

LWG discussion in Belfast notes that 3329 also touches the definition of totally_ordered_with; the two sets of changes are consistent.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: voting -> wp
2020-01-17 04:54:50adminsetstatus: ready -> voting
2019-11-08 15:56:47adminsetmessages: + msg10809
2019-11-08 15:56:47adminsetstatus: new -> ready
2019-11-08 11:53:29adminsetmessages: + msg10803
2019-11-08 00:00:00admincreate