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.
counted_iterator
and default_sentinel_t
should be noexcept
Section: 24.5.7.1 [counted.iterator], 24.5.7.5 [counted.iter.nav], 24.5.7.6 [counted.iter.cmp] Status: New Submitter: Hewill Kang Opened: 2025-04-18 Last modified: 2025-04-21
Priority: Not Prioritized
View all other issues in [counted.iterator].
View all issues with New status.
Discussion:
counted_iterator
can be compared or subtracted from default_sentinel_t
,
which only involves simple integer arithmetic and does not have any Preconditions.
noexcept
.
Proposed resolution:
This wording is relative to N5008.
Modify 24.5.7.1 [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; […] }; […] }
Modify 24.5.7.5 [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;
Modify 24.5.7.6 [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;