On Wed, 14 Feb 2024 at 18:39, François Dumont <frs.dum...@gmail.com> wrote:

> libstdc++: [_GLIBCXX_DEBUG] Fix std::__niter_base behavior
>
> std::__niter_base is used in _GLIBCXX_DEBUG mode to remove _Safe_iterator<>
> wrapper on random access iterators. But doing so it should also preserve
> original
> behavior to remove __normal_iterator wrapper.
>
> libstdc++-v3/ChangeLog:
>
>      * include/bits/stl_algobase.h (std::__niter_base): Redefine the
> overload
>      definitions for __gnu_debug::_Safe_iterator.
>      * include/debug/safe_iterator.tcc (std::__niter_base): Adapt
> declarations.
>
> Ok to commit once all tests completed (still need to check pre-c++11) ?
>


The declaration in  include/bits/stl_algobase.h has a noexcept-specifier
but the definition in include/debug/safe_iterator.tcc does not have one -
that seems wrong (I'm surprised it even compiles).
Just using std::is_nothrow_copy_constructible<_Ite> seems simpler, that
will be true for __normal_iterator<I, C> if
is_nothrow_copy_constructible<I> is true.

The definition in include/debug/safe_iterator.tcc should use
std::declval<_Ite>() not declval<_Ite>(). Is there any reason why the
definition uses a late-specified-return-type (i.e. auto and ->) when the
declaration doesn't?

Reply via email to