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.

3713. Sorted with respect to comparator (only)

Section: 26.8.1 [alg.sorting.general] Status: C++23 Submitter: Casey Carter Opened: 2022-06-10 Last modified: 2023-11-22

Priority: Not Prioritized

View all issues with C++23 status.

Discussion:

P0896R4 changed the term of art "sorted with respect to comparator" defined in 26.8.1 [alg.sorting.general] paragraph 5 to "sorted with respect to comparator and projection." That proposal updated the algorithm specifications consistently. However, there were uses of the old term outside of 26 [algorithms] that are now without meaning. We should bring back the term "sorted with respect to comparator" to fix that lack.

[2022-06-21; Reflector poll]

Set status to Tentatively Ready after eight votes in favour during reflector poll.

[2022-07-15; LWG telecon: move to Ready]

[2022-07-25 Approved at July 2022 virtual plenary. Status changed: Ready → WP.]

Proposed resolution:

This wording is relative to N4910.

  1. Modify 26.8.1 [alg.sorting.general] as indicated:

    -5- A sequence is sorted with respect to a comp and proj for a comparator and projection comp and proj if for every iterator i pointing to the sequence and every non-negative integer n such that i + n is a valid iterator pointing to an element of the sequence,

    bool(invoke(comp, invoke(proj, *(i + n)), invoke(proj, *i)))
    

    is false.

    -?- A sequence is sorted with respect to a comparator comp for a comparator comp if it is sorted with respect to comp and identity{} (the identity projection).