On 10/03/20 17:52 +0000, Jonathan Wakely wrote:
On 10/03/20 11:40 +0000, Jonathan Wakely wrote:
G++ fails to diagnose this non-dependent expression, but Clang doesn't
like it.
PR c++/94117
* include/std/ranges (ranges::transform_view::_Iterator::iter_move):
Change expression in noexcept-specifier to match function body.
This patch goes further and removes the __iter_move helper completely,
and the __iter_swap one, in transform_view.
It also does the same in split_view, and fixes a bug where the
noexcept-specifier was always false.
I've also added new _M_i_current() accessors (overloaded for const and
non-const) to return _M_i.__current(). Using this instead of
_M_i._M_current fixes a bug in inner-iterator::operator*() (which is
also present in the working draft).
I missed a few more bugs in the outer iterator, where _M_current was
being used directly despite only being valid for forward ranges. Fixed
by this patch.
Tested powerpc64le-linux, committed to master.
commit 0b7f1e24316cfc1f85408918d1734d3266d65089
Author: Jonathan Wakely <jwak...@redhat.com>
Date: Tue Mar 10 22:15:58 2020 +0000
libstdc++: Fix uses of _M_current in split_view's outer iterator
These direct uses of _M_current should all be __current() so they are
valid when the base type doesn't satisfy the forward_range concept.
* include/std/ranges (split_view::_OuterIter::__at_end): Use __current
instead of _M_current.
(split_view::_OuterIter::operator++): Likewise.
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 4dc7342e2f7..de120d6b55d 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -2703,9 +2703,9 @@ namespace views
constexpr bool
__at_end() const
- { return _M_current == ranges::end(_M_parent->_M_base); }
+ { return __current() == ranges::end(_M_parent->_M_base); }
- // XXX: [24.7.11.3.1]
+ // [range.split.outer] p1
// Many of the following specifications refer to the notional member
// current of outer-iterator. current is equivalent to current_ if
// V models forward_range, and parent_->current_ otherwise.
@@ -2798,21 +2798,21 @@ namespace views
operator++()
{
const auto __end = ranges::end(_M_parent->_M_base);
- if (_M_current == __end)
+ if (__current() == __end)
return *this;
const auto [__pbegin, __pend] = subrange{_M_parent->_M_pattern};
if (__pbegin == __pend)
- ++_M_current;
+ ++__current();
else
do
{
auto [__b, __p]
- = __detail::mismatch(std::move(_M_current), __end,
+ = __detail::mismatch(std::move(__current()), __end,
__pbegin, __pend);
- _M_current = std::move(__b);
+ __current() = std::move(__b);
if (__p == __pend)
break;
- } while (++_M_current != __end);
+ } while (++__current() != __end);
return *this;
}