From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1984) id 48BE93857029; Fri, 17 Jul 2020 13:12:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 48BE93857029 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594991521; bh=B9hGaYoYfAjqjGWGGtO1c3h2+AnZSZSJD9c5EotiEWk=; h=From:To:Subject:Date:From; b=FxbFn8OiCtdM6TZ8hnqqbVJ+akPwSoYAl3q3H+inbT/Tl7dGhL2IeoAOhCIm8hmDJ 207TvC3oR132joc/XtwKNx/ZX0ZVvz+0F8naRYXRO65fcwkOeH+yEAwbHCe7DUiOyZ HnvoqBLFZCh2tfDgKOrcHLRa8HEwlA5PffnswddU= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tamar Christina To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/arm-perf-staging)] libstdc++: P1983R0 Wording for GB301, US296, US292, US291, and US283 X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/vendors/ARM/heads/arm-perf-staging X-Git-Oldrev: 6fa35f0e2843759cf5a4f2d309aa26090fd25f80 X-Git-Newrev: 242b4fb7f4e6c6224e727fa5e9ed8a776d16ccf9 Message-Id: <20200717131201.48BE93857029@sourceware.org> Date: Fri, 17 Jul 2020 13:12:01 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jul 2020 13:12:01 -0000 https://gcc.gnu.org/g:242b4fb7f4e6c6224e727fa5e9ed8a776d16ccf9 commit 242b4fb7f4e6c6224e727fa5e9ed8a776d16ccf9 Author: Patrick Palka Date: Tue Feb 18 12:31:25 2020 -0500 libstdc++: P1983R0 Wording for GB301, US296, US292, US291, and US283 Among other changes, P1983R0 resolves LWG 3278 in a different way, so this patch also reverts the already-applied wording of LWG 3278. The wording for US291 (the join_view::begin hunk) also required adding the friend _Iterator to join_view::_Iterator. This friend is needed so that _Iterator's converting constructor can access the private members of an _Iterator of the opposite constness. The wording for US283 has already been applied it seems. libstdc++-v3/ChangeLog: P1983R0 Wording for GB301, US296, US292, US291, and US283 * include/std/ranges (filter_view::pred): New member function. (join_view::_Iterator::_Iterator): Remove now-redundant comment since P1983R0 fixes the highlighted issue in the same way. (join_view::_Iterator<_Const>): Add friend join_view::_Iterator. (join_view::_M_inner): Remove mutable specifier, effectively reverting the proposed wording changes of P3278. (join_view::begin): Refine the condition for when to return a const iterator. (split_view::_OuterIter::_OuterIter): Adjust constraints. * testsuite/std/ranges/adaptors/filter.cc: Test that filter_view::pred exists and works. Diff: --- libstdc++-v3/ChangeLog | 16 ++++++++++++++++ libstdc++-v3/include/std/ranges | 18 +++++++++++------- libstdc++-v3/testsuite/std/ranges/adaptors/filter.cc | 2 ++ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 458c9553a95..b60f5c301b4 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,19 @@ +2020-02-18 Patrick Palka + + P1983R0 Wording for GB301, US296, US292, US291, and US283 + * include/std/ranges (filter_view::pred): New member function. + (join_view::_Iterator::_Iterator): Remove now-redundant comment since + P1983R0 fixes the highlighted issue in the same way. + (join_view::_Iterator<_Const>): Add friend + join_view::_Iterator. + (join_view::_M_inner): Remove mutable specifier, effectively reverting + the proposed wording changes of P3278. + (join_view::begin): Refine the condition for when to return a const + iterator. + (split_view::_OuterIter::_OuterIter): Adjust constraints. + * testsuite/std/ranges/adaptors/filter.cc: Test that filter_view::pred + exists and works. + 2020-02-18 Jonathan Wakely PR libstdc++/93818 diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index e6bdac315c0..e0eb84748a2 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -1488,6 +1488,10 @@ namespace views base() && { return std::move(_M_base); } + constexpr const _Pred& + pred() const + { return *_M_pred; } + constexpr _Iterator begin() { @@ -2336,8 +2340,6 @@ namespace views _Iterator() = default; - // XXX: had to change the type of __outer from iterator_t<_Vp> to - // iterator_t<_Base> here, a possible defect in the spec? constexpr _Iterator(_Parent& __parent, _Outer_iter __outer) : _M_outer(std::move(__outer)), @@ -2437,6 +2439,7 @@ namespace views noexcept(noexcept(ranges::iter_swap(__x._M_inner, __y._M_inner))) { return ranges::iter_swap(__x._M_inner, __y._M_inner); } + friend _Iterator; friend _Sentinel<_Const>; }; @@ -2475,8 +2478,7 @@ namespace views _Vp _M_base = _Vp(); // XXX: _M_inner is "present only when !is_reference_v<_InnerRange>" - // Applied P3278 and made this field mutable. - [[no_unique_address]] mutable + [[no_unique_address]] conditional_t, all_view<_InnerRange>, __detail::_Empty> _M_inner; @@ -2509,8 +2511,10 @@ namespace views constexpr auto begin() { - return _Iterator<__detail::__simple_view<_Vp>>{*this, - ranges::begin(_M_base)}; + constexpr bool __use_const + = (__detail::__simple_view<_Vp> + && is_reference_v>); + return _Iterator<__use_const>{*this, ranges::begin(_M_base)}; } constexpr auto @@ -2676,7 +2680,7 @@ namespace views constexpr _OuterIter(_OuterIter __i) requires _Const - && convertible_to, iterator_t> + && convertible_to, iterator_t<_Base>> : _M_parent(__i._M_parent), _M_current(std::move(__i._M_current)) { } diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/filter.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/filter.cc index 83d52967a0f..4edbf0b657d 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/filter.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/filter.cc @@ -46,6 +46,8 @@ test01() static_assert(ranges::range>); VERIFY( ranges::equal(v, (int[]){1,3,5}) ); VERIFY( ranges::equal(v | views::reverse, (int[]){5,3,1}) ); + VERIFY( v.pred()(3) == true ); + VERIFY( v.pred()(4) == false ); } void