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.

2824. list::sort should say that the order of elements is unspecified if an exception is thrown

Section: 23.3.9.5 [list.ops] Status: C++17 Submitter: Tim Song Opened: 2016-11-16 Last modified: 2017-07-30

Priority: 0

View all other issues in [list.ops].

View all issues with C++17 status.

Discussion:

Sometime between N1638 and N1804 the sentence "If an exception is thrown the order of the elements in the list is indeterminate." in the specification of list::sort went missing. This suspiciously coincided with the editorial change that "consolidated definitions of "Stable" in the library clauses" (N1805).

forward_list::sort says that "If an exception is thrown the order of the elements in *this is unspecified"; list::sort should do the same.

[2017-01-27 Telecon]

Priority 0

Proposed resolution:

This wording is relative to N4606.

  1. Edit 23.3.9.5 [list.ops] p29 as indicated:

    void sort();
    template <class Compare> void sort(Compare comp);
    

    -28- Requires: operator< (for the first version) or comp (for the second version) shall define a strict weak ordering (26.8 [alg.sorting]).

    -29- Effects: Sorts the list according to the operator< or a Compare function object. If an exception is thrown, the order of the elements in *this is unspecified. Does not affect the validity of iterators and references.

    […]