This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.

3432. Missing requirement for comparison_category

Section: 23.3.4 [string.view.comparison] Status: C++23 Submitter: Jonathan Wakely Opened: 2020-04-19 Last modified: 2023-11-22

Priority: 0

View all issues with C++23 status.

Discussion:

It's not clear what happens if a program-defined character traits type defines comparison_category as a synonym for void, or some other bogus type.

Discussion on the LWG reflector settled on making it ill-formed at the point of use.

[2020-07-17; Moved to Ready in telecon]

[2020-11-09 Approved In November virtual meeting. Status changed: Ready → WP.]

Proposed resolution:

This wording is relative to N4861.

  1. Modify 23.3.4 [string.view.comparison] by adding a new paragraph after p3:

    As result of reflector discussion we decided to make a drive-by fix in p3 below.

    template<class charT, class traits>
      constexpr see below operator<=>(basic_string_view<charT, traits> lhs,
                                      basic_string_view<charT, traits> rhs) noexcept;
    

    -3- Let R denote the type traits::comparison_category if that qualified-id is valid and denotes a type (13.10.3 [temp.deduct])it exists, otherwise R is weak_ordering.

    -?- Mandates: R denotes a comparison category type (17.11.2 [cmp.categories]).

    -4- Returns: static_cast<R>(lhs.compare(rhs) <=> 0).