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

3912. enumerate_view::iterator::operator- should be noexcept

Section: 25.7.24.3 [range.enumerate.iterator] Status: WP Submitter: Hewill Kang Opened: 2023-03-27 Last modified: 2023-11-22

Priority: Not Prioritized

View other active issues in [range.enumerate.iterator].

View all other issues in [range.enumerate.iterator].

View all issues with WP status.

Discussion:

The distance between two enumerate_view::iterator is calculated by subtracting two integers, which never throws.

[2023-05-24; Reflector poll]

Set status to Tentatively Ready after five votes in favour during reflector poll.

[2023-06-17 Approved at June 2023 meeting in Varna. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4944.

  1. Modify 25.7.24.3 [range.enumerate.iterator] as indicated:

    
    namespace std::ranges {
      template<view V>
        requires range-with-movable-references<V>
      template<bool Const>
      class enumerate_view<V>::iterator {
        […]
        public:
        […]
        friend constexpr difference_type operator-(const iterator& x, const iterator& y) noexcept;
        […]
      }
      […]
    }
    
    […]
    
    friend constexpr difference_type operator-(const iterator& x, const iterator& y) noexcept;
    

    -19- Effects: Equivalent to: return x.pos_ - y.pos_;