https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116399
--- Comment #20 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Jonathan Wakely from comment #19)
> We could do this, and rely on the fact that the number of aliases is always
> small so that we can claim it's O(1):
>
> --- a/libstdc++-v3/include/std/text_encoding
> +++ b/libstdc++-v3/include/std/text_encoding
> @@ -644,6 +644,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> return __i;
> }
>
> + friend constexpr difference_type
> + operator-(_Sentinel __s, _Iterator __i)
> + {
> + __glibcxx_assert(__i._M_rep != nullptr);
> + difference_type __n = 0;
> + if (const _Rep* __rep = __i._M_rep)
> + while (__rep[__n]._M_id == __i._M_id)
> + ++__n;
> + return __n;
> + }
> +
> + friend constexpr difference_type
> + operator-(_Iterator __i, _Sentinel __s)
> + { return -(__s - __i); }
> +
> private:
> friend struct text_encoding;
I can submit an LWG for this, unless you're still strongly NAD about
text_encoding::aliases_view being sized_range. :)