Title
Operators that interact with `counted_iterator` and `default_sentinel_t` should be `noexcept`
Status
wp
Section
[counted.iterator][counted.iter.nav][counted.iter.cmp]
Submitter
Hewill Kang

Created on 2025-04-18.00:00:00 last changed 1 week ago

Messages

Date: 2025-06-23.16:37:24

Proposed resolution:

This wording is relative to N5008.

  1. Modify [counted.iterator] as indicated:

    namespace std {
      template<input_or_output_iterator I>
      class counted_iterator {
      public:
        […]
        friend constexpr iter_difference_t<I> operator-(
          const counted_iterator& x, default_sentinel_t) noexcept;
        friend constexpr iter_difference_t<I> operator-(
          default_sentinel_t, const counted_iterator& y) noexcept;
        […]
        friend constexpr bool operator==(
          const counted_iterator& x, default_sentinel_t) noexcept;
        […]
      };
      […]
    }
    
  2. Modify [counted.iter.nav] as indicated:

    friend constexpr iter_difference_t<I> operator-(
      const counted_iterator& x, default_sentinel_t) noexcept;
    

    -15- Effects: Equivalent to: return -x.length;

    friend constexpr iter_difference_t<I> operator-(
      default_sentinel_t, const counted_iterator& y) noexcept;
    

    -16- Effects: Equivalent to: return y.length;

  3. Modify [counted.iter.cmp] as indicated:

    friend constexpr bool operator==(
      const counted_iterator& x, default_sentinel_t) noexcept;
    

    -3- Effects: Equivalent to: return x.length == 0;

Date: 2025-06-23.16:37:24

[ Sofia 2025-06-21; Status changed: Voting → WP. ]

Date: 2025-06-15.00:00:00

[ 2025-06-12; Reflector poll ]

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

Date: 2025-04-18.00:00:00

`counted_iterator` can be compared or subtracted from `default_sentinel_t`, which only involves simple integer arithmetic and does not have any Preconditions.

In this case, it is reasonable to declare them as noexcept.

History
Date User Action Args
2025-06-23 16:37:24adminsetmessages: + msg14864
2025-06-23 16:37:24adminsetstatus: voting -> wp
2025-06-12 20:59:27adminsetstatus: ready -> voting
2025-06-12 20:55:03adminsetmessages: + msg14804
2025-06-12 20:55:03adminsetstatus: new -> ready
2025-04-21 10:17:51adminsetmessages: + msg14727
2025-04-18 00:00:00admincreate