Title
move_iterator::operator* should have conditional noexcept specification
Status
new
Section
[move.iter.elem]
Submitter
Hewill Kang

Created on 2024-07-03.00:00:00 last changed 4 months ago

Messages

Date: 2024-08-02.21:14:44

Proposed resolution:

This wording is relative to N4981.

  1. Modify [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 [move.iter.elem] as indicated:

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

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

Date: 2024-08-15.00:00:00

[ 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?"

Date: 2024-07-03.00:00:00

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.

History
Date User Action Args
2024-08-02 21:14:44adminsetmessages: + msg14281
2024-07-07 13:22:10adminsetmessages: + msg14231
2024-07-03 00:00:00admincreate