From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120748 invoked by alias); 18 Feb 2020 19:31:36 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 120734 invoked by uid 89); 18 Feb 2020 19:31:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Feb 2020 19:31:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582054293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2pYbBTh3wKnoa9JayJramrxHMKCmg/BpXsZo4TTVeic=; b=bJKyrMELcZuuSNZeF3VQ4XasCdK3cSVRphnSFPiqllTWFi5N+e70ulyIsx2ADNi6veGz3k 0RyIFr9F1M+I/tExbxVW68jqnPHIl9XalGWqy6ojsYh7QsDJTE0iK78SkW1yl/wHF14VRz la69Xd1+k2V/4z0QgZVb9cRRudrSsMo= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-6-NTRvtLepN-SZy2Gj8Ng8YQ-1; Tue, 18 Feb 2020 14:31:31 -0500 Received: by mail-qk1-f199.google.com with SMTP id c206so14864681qkg.6 for ; Tue, 18 Feb 2020 11:31:31 -0800 (PST) Return-Path: Received: from [192.168.1.130] (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id x41sm2379434qtj.52.2020.02.18.11.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 11:31:28 -0800 (PST) From: Patrick Palka Date: Tue, 18 Feb 2020 19:31:00 -0000 To: Patrick Palka cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, jwakely@redhat.com Subject: Re: [PATCH] libstdc++: P1983R0 Wording for GB301, US296, US292, US291, and US283 In-Reply-To: <20200218191404.1118768-1-ppalka@redhat.com> Message-ID: References: <20200218191404.1118768-1-ppalka@redhat.com> User-Agent: Alpine 2.22 (DEB 395 2020-01-19) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg01069.txt.bz2 On Tue, 18 Feb 2020, Patrick Palka wrote: > Among other changes, P1983R0 resolves LWG 3278 in a different way, so thi= s patch > also reverts the already-applied change of LWG 3278. >=20 > The wording for US283 has already been applied it seems. >=20 > libstdc++-v3/ChangeLog: >=20 > 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::_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. Oops, this patch is incomplete, it breaks the join_view adaptor test due to a missing friend, sorry about that. Here's the complete and tested patch: -- >8 -- Subject: [PATCH] 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 change 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 require= d for one of this iterator's converting constructors to be able to access the pri= vate 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. --- libstdc++-v3/include/std/ranges | 18 +++++++++++------- .../testsuite/std/ranges/adaptors/filter.cc | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ran= ges index a04387a75c4..fb6e67dd0b3 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -1556,6 +1556,10 @@ namespace views base() && { return std::move(_M_base); } =20 + constexpr const _Pred& + pred() const + { return *_M_pred; } + constexpr _Iterator begin() { @@ -2421,8 +2425,6 @@ namespace views =20 _Iterator() =3D default; =20 - // 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, iterator_t<_Base> __outer) : _M_outer(std::move(__outer)), @@ -2523,6 +2525,7 @@ namespace views noexcept(noexcept(ranges::iter_swap(__x._M_inner, __y._M_inner))) { return ranges::iter_swap(__x._M_inner, __y._M_inner); } =20 + friend _Iterator; friend _Sentinel<_Const>; }; =20 @@ -2561,8 +2564,7 @@ namespace views _Vp _M_base =3D _Vp(); =20 // 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; =20 @@ -2595,8 +2597,10 @@ namespace views constexpr auto begin() { - return _Iterator<__detail::__simple_view<_Vp>>{*this, - ranges::begin(_M_base)}; + constexpr bool __use_const + =3D (__detail::__simple_view<_Vp> + && is_reference_v>); + return _Iterator<__use_const>{*this, ranges::begin(_M_base)}; } =20 constexpr auto @@ -2762,7 +2766,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)) { } =20 diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/filter.cc b/libstdc= ++-v3/testsuite/std/ranges/adaptors/filter.cc index 834d10f7f91..84858798dda 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/filter.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/filter.cc @@ -48,6 +48,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) =3D=3D true ); + VERIFY( v.pred()(4) =3D=3D false ); } =20 void --=20 2.25.1.291.ge68e29171c