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

4115. move_iterator::operator* should have conditional noexcept specification

Section: 24.5.4.6 [move.iter.elem] Status: New Submitter: Hewill Kang Opened: 2024-07-03 Last modified: 2024-08-02

Priority: 4

View all other issues in [move.iter.elem].

View all issues with New status.

Discussion:

For move_iterator, dereferencing it is actually equivalent to applying iter_move to it.

However, unlike the latter, move_iterator's dereference operator lacks a noexcept specification, which seems to be an oversight given that the standard goes to such great lengths to preserve the noexceptness of iter_move, and the main purpose of move_iterator is precisely to apply iter_move to the underlying iterator via dereferencing.

[2024-08-02; Reflector poll]

Set priority to 4 after reflector poll. "Do we have evidence conditional noexcept matters here? Do we have a policy that operator* should be noexcept whenever possible? What criteria are we using to decide here?"

Proposed resolution:

This wording is relative to N4981.

  1. Modify 24.5.4.2 [move.iterator] as indicated:

    namespace std {
      template<class Iterator>
      class move_iterator {
      public:
        […]
        constexpr reference operator*() const noexcept(noexcept(ranges::iter_move(current)));
        […]
      };
    }
    
  2. Modify 24.5.4.6 [move.iter.elem] as indicated:

    constexpr reference operator*() const noexcept(noexcept(ranges::iter_move(current)));
    

    -1- Effects: Equivalent to: return ranges::iter_move(current);