[Bug libstdc++/100631] ranges::elements_view:: _Sentinel is missing __distance_from() that can access _M_current of _Iterator

hewillk at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue May 18 05:32:03 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100631

--- Comment #7 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to CVS Commits from comment #6)
> The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
> 
> https://gcc.gnu.org/g:2e2eef80ac0c21f9533e6791ccf5e29458cbb77c
> 
> commit r12-854-g2e2eef80ac0c21f9533e6791ccf5e29458cbb77c
> Author: Patrick Palka <ppalka@redhat.com>
> Date:   Tue May 18 00:26:07 2021 -0400
> 
>     libstdc++: Fix miscellaneous issues with elements_view::_Sentinel
> [PR100631]
>     
>     libstdc++-v3/ChangeLog:
>     
>             PR libstdc++/100631
>             * include/std/ranges (elements_view::_Iterator): Also befriend
>             _Sentinel<!_Const>.
>             (elements_view::_Sentinel::_M_equal): Templatize.
>             (elements_view::_Sentinel::_M_distance_from): Split out from ...
>             (elements_view::_Sentinel::operator-): ... here.  Depend on
>             _Base2 instead of _Base in the return type.
>             * testsuite/std/ranges/adaptors/elements.cc (test06, test07):
>             New tests.



Hey, Patrick, you missed the second one:


    template<bool _Const2,
             typename _Base2 = __detail::__maybe_const_t<_Const2, _Vp>>
    requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base2>>
    friend constexpr range_difference_t<_Base2>
    operator-(const _Iterator<_Const2>& __x, const _Sentinel& __y)
    { return __x._M_current - __y._M_end; }


this should be return -__y._M_distance_from(__x).


More information about the Gcc-bugs mailing list