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

### 2492. Clarify requirements for `comp`

Section: 27.8 [alg.sorting] Status: C++17 Submitter: Anton Savin Opened: 2015-04-14 Last modified: 2017-07-30

Priority: 0

View all other issues in [alg.sorting].

View all issues with C++17 status.

Discussion:

N4296 27.8 [alg.sorting]/3 reads:

> For all algorithms that take `Compare`, there is a version that uses `operator<` instead. That is, `comp(*i,*j) != false` defaults to `*i < *j != false`. For algorithms other than those described in 25.4.3 to work correctly, `comp` has to induce a strict weak ordering on the values.

So it's not specified clearly what happens if `comp` or `operator<` don't induce a strict weak ordering. Is it undefined or implementation-defined behavior? It seems that it should be stated more clearly that the behavior is undefined.

[2015-05, Lenexa]

Move to Immediate.

Proposed resolution:

This wording is relative to N4431.

1. Change 27.8 [alg.sorting]/3 to the following:

   > For all algorithms that take `Compare`, there is a version that uses `operator<` instead. That is, `comp(*i, *j) != false` defaults to `*i < *j != false`. For algorithms other than those described in 25.4.3 to work correctly, `comp` shall has to induce a strict weak ordering on the values.