On Tue, 16 Jan 2024 at 14:07, Jonathan Wakely wrote: > > On 15/01/24 19:09 -0500, Patrick Palka wrote: > >> + friend _Iterator > >> + operator+(_Iterator __i, difference_type __n) > > > >constexpr? > > Fixed. I've added tests that all iterator ops are usable in constant > expressions, which found a bug in operator+= (it didn't let you > increment one past the end of the range).
I found another bug in operator+= which is fixed and tested like so: --- a/libstdc++-v3/include/std/text_encoding +++ b/libstdc++-v3/include/std/text_encoding @@ -584,7 +584,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION *this == _Iterator{}; } } - __glibcxx_assert(_M_rep != nullptr); + if (__n != 0) + __glibcxx_assert(_M_rep != nullptr); return *this; } --- a/libstdc++-v3/testsuite/std/text_encoding/requirements.cc +++ b/libstdc++-v3/testsuite/std/text_encoding/requirements.cc @@ -67,6 +67,11 @@ test_constexpr_iterator() VERIFY( *(iter + 1) == iter[1] ); VERIFY( (1 + iter - 1) == begin ); VERIFY( (-1 + (iter - -2) + -1) == begin ); + + std::ranges::iterator_t<std::text_encoding::aliases_view> singular; + VERIFY( (singular + 0) == singular ); + VERIFY( (singular - 0) == singular ); + return true; } static_assert( test_constexpr_iterator() );