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.

3704. LWG 2059 added overloads that might be ill-formed for sets

Section: 24.4.6.1 [set.overview], 24.4.7.1 [multiset.overview], 24.5.6.1 [unord.set.overview], 24.5.7.1 [unord.multiset.overview] Status: C++23 Submitter: Jonathan Wakely Opened: 2022-05-25 Last modified: 2023-11-22

Priority: Not Prioritized

View all issues with C++23 status.

Discussion:

The restored erase(iterator) overloads introduced by LWG 2059(i) would be duplicates of the erase(const_iterator) ones if iterator and const_iterator are the same type, which is allowed for sets.

We should constrain them (or add prose) so that the erase(iterator) overloads are only present when the iterator types are distinct.

This applies to set, multiset, unordered_set, unordered_multiset (and flat_set and flat_multiset).

[2022-06-21; Reflector poll]

Set status to Tentatively Ready after seven 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 24.4.6.1 [set.overview], class template set synopsis, as indicated:

    iterator erase(iterator position) requires (!same_as<iterator, const_iterator>);
    iterator erase(const_iterator position);
    
  2. Modify 24.4.7.1 [multiset.overview], class template multiset synopsis, as indicated:

    iterator erase(iterator position) requires (!same_as<iterator, const_iterator>);
    iterator erase(const_iterator position);
    
  3. Modify 24.5.6.1 [unord.set.overview], class template unordered_set synopsis, as indicated:

    iterator erase(iterator position) requires (!same_as<iterator, const_iterator>);
    iterator erase(const_iterator position);
    
  4. Modify 24.5.7.1 [unord.multiset.overview], class template unordered_multiset synopsis, as indicated:

    iterator erase(iterator position) requires (!same_as<iterator, const_iterator>);
    iterator erase(const_iterator position);