From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 7F51B3858D39 for ; Fri, 14 Apr 2023 04:00:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F51B3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681444847; 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; bh=3q234YHJ6R6x7OQl7LxdtXR3Jj+PrwznrT3sVNPNYC8=; b=caGCBJFb1o1DvVHp/5jO96Jr4487YUp/sIhdrxoS05lvoN5GbuI8PVO7sgxulPANOIXBRT JKSNt0DV+HCQE4Z/jy3/dBZOOTcHrF+YuBUaCQS1yEO2NlXPkcBDRmcd3VkwONJpugJjOX s/vfwAZuPE8Ve8QXR76gqEGLwnc7MLc= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-CiHjknR7PMCK6hiU4an6Sw-1; Fri, 14 Apr 2023 00:00:46 -0400 X-MC-Unique: CiHjknR7PMCK6hiU4an6Sw-1 Received: by mail-qv1-f69.google.com with SMTP id o14-20020a0cc38e000000b005e62747d93aso10941069qvi.11 for ; Thu, 13 Apr 2023 21:00:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681444845; x=1684036845; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3q234YHJ6R6x7OQl7LxdtXR3Jj+PrwznrT3sVNPNYC8=; b=L+nt9e3kpuEZbnkJwiP02M0tpSCyPMTSBA/tLNxIyraZL9OINjzCd4kWXFl12ew4H5 mmb6y6cxk6WeHM7CcoF8SP6jvxecNU/s9gpXlY9GFarzPVwJOE7zydx+fTTOfUIAi57N W6bFPeLSC5ypr5aFGAlekdc77Yuk9Gd9/OeRnATkdGxRVoa1h1kqE7FjfZBqFB+10J2m 1sJq7CG/I6iuf58x1/soixbgWaiw9X6X3G/mgTi2/PZJSZbnnb3yUHPC7q+oJZdDuD2P B9d3aw6fgmWhE6H5RlAVAW+U2wObPf3CtdQ826kXJP94u8iHZxVRQxgxCL494KIHJEge yQZg== X-Gm-Message-State: AAQBX9eKEab1oy256rOcy8kIAEzy4uscirOBVrKPu3D19gNr/m/N74nV 57iQPZjn9UzobAFfgDTy5Vw+S3cbmqMSp2UaSMkWWGuqEFQXH4n9XQYZrIAfn4C81UeJnYAEbAe cUzVw0rhby5KmQ37h/QT3C0ftV1UymIT4GKEaxkTemd0mZtykdrSSSomei1YWdtrTbYNAwziWGn o= X-Received: by 2002:a05:6214:1c86:b0:5ef:4435:f1cd with SMTP id ib6-20020a0562141c8600b005ef4435f1cdmr1006733qvb.27.1681444845062; Thu, 13 Apr 2023 21:00:45 -0700 (PDT) X-Google-Smtp-Source: AKy350ZBHNg4jyttTX6i4k4ITg5dwP0QojfRBS6qYpTuwyv3RE8WdjTPyke4loM0dDOKpQDB5BzERg== X-Received: by 2002:a05:6214:1c86:b0:5ef:4435:f1cd with SMTP id ib6-20020a0562141c8600b005ef4435f1cdmr1006709qvb.27.1681444844687; Thu, 13 Apr 2023 21:00:44 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id dp20-20020a05621409d400b005dd8b9345d6sm871169qvb.110.2023.04.13.21.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Apr 2023 21:00:44 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Patrick Palka Subject: [PATCH 1/2] libstdc++: Move down definitions of ranges::cbegin/cend/cetc Date: Fri, 14 Apr 2023 00:00:41 -0400 Message-ID: <20230414040042.1498825-1-ppalka@redhat.com> X-Mailer: git-send-email 2.40.0.335.g9857273be0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This moves down the definitions of the const range access CPOs to after the definition of input_range in preparation for implementing P2287R4 which redefines these CPOs in a way that indirectly uses input_range. tested on x86_64-pc-linux-gnu, does this look OK for trunk? libstdc++-v3/ChangeLog: * include/bits/ranges_base.h (__cust_access::__as_const) (__cust_access::_CBegin, __cust::cbegin) (__cust_access::_CEnd, __cust::cend) (__cust_access::_CRBegin, __cust::crbegin) (__cust_access::_CREnd, __cust::crend) (__cust_access::_CData, __cust::cdata): Move down definitions to shortly after the definition of input_range. --- libstdc++-v3/include/bits/ranges_base.h | 174 +++++++++++++----------- 1 file changed, 91 insertions(+), 83 deletions(-) diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h index 86952b34096..c89cb3e976a 100644 --- a/libstdc++-v3/include/bits/ranges_base.h +++ b/libstdc++-v3/include/bits/ranges_base.h @@ -177,45 +177,6 @@ namespace ranges } }; - // If _To is an lvalue-reference, return const _Tp&, otherwise const _Tp&&. - template - constexpr decltype(auto) - __as_const(_Tp& __t) noexcept - { - static_assert(std::is_same_v<_To&, _Tp&>); - - if constexpr (is_lvalue_reference_v<_To>) - return const_cast(__t); - else - return static_cast(__t); - } - - struct _CBegin - { - template - [[nodiscard]] - constexpr auto - operator()(_Tp&& __e) const - noexcept(noexcept(_Begin{}(__cust_access::__as_const<_Tp>(__e)))) - requires requires { _Begin{}(__cust_access::__as_const<_Tp>(__e)); } - { - return _Begin{}(__cust_access::__as_const<_Tp>(__e)); - } - }; - - struct _CEnd final - { - template - [[nodiscard]] - constexpr auto - operator()(_Tp&& __e) const - noexcept(noexcept(_End{}(__cust_access::__as_const<_Tp>(__e)))) - requires requires { _End{}(__cust_access::__as_const<_Tp>(__e)); } - { - return _End{}(__cust_access::__as_const<_Tp>(__e)); - } - }; - template concept __member_rbegin = requires(_Tp& __t) { @@ -337,32 +298,6 @@ namespace ranges } }; - struct _CRBegin - { - template - [[nodiscard]] - constexpr auto - operator()(_Tp&& __e) const - noexcept(noexcept(_RBegin{}(__cust_access::__as_const<_Tp>(__e)))) - requires requires { _RBegin{}(__cust_access::__as_const<_Tp>(__e)); } - { - return _RBegin{}(__cust_access::__as_const<_Tp>(__e)); - } - }; - - struct _CREnd - { - template - [[nodiscard]] - constexpr auto - operator()(_Tp&& __e) const - noexcept(noexcept(_REnd{}(__cust_access::__as_const<_Tp>(__e)))) - requires requires { _REnd{}(__cust_access::__as_const<_Tp>(__e)); } - { - return _REnd{}(__cust_access::__as_const<_Tp>(__e)); - } - }; - template concept __member_size = !disable_sized_range> && requires(_Tp& __t) @@ -547,36 +482,18 @@ namespace ranges } }; - struct _CData - { - template - [[nodiscard]] - constexpr auto - operator()(_Tp&& __e) const - noexcept(noexcept(_Data{}(__cust_access::__as_const<_Tp>(__e)))) - requires requires { _Data{}(__cust_access::__as_const<_Tp>(__e)); } - { - return _Data{}(__cust_access::__as_const<_Tp>(__e)); - } - }; - } // namespace __cust_access inline namespace __cust { inline constexpr __cust_access::_Begin begin{}; inline constexpr __cust_access::_End end{}; - inline constexpr __cust_access::_CBegin cbegin{}; - inline constexpr __cust_access::_CEnd cend{}; inline constexpr __cust_access::_RBegin rbegin{}; inline constexpr __cust_access::_REnd rend{}; - inline constexpr __cust_access::_CRBegin crbegin{}; - inline constexpr __cust_access::_CREnd crend{}; inline constexpr __cust_access::_Size size{}; inline constexpr __cust_access::_SSize ssize{}; inline constexpr __cust_access::_Empty empty{}; inline constexpr __cust_access::_Data data{}; - inline constexpr __cust_access::_CData cdata{}; } /// [range.range] The range concept. @@ -690,6 +607,97 @@ namespace ranges concept common_range = range<_Tp> && same_as, sentinel_t<_Tp>>; + namespace __cust_access + { + // If _To is an lvalue-reference, return const _Tp&, otherwise const _Tp&&. + template + constexpr decltype(auto) + __as_const(_Tp& __t) noexcept + { + static_assert(std::is_same_v<_To&, _Tp&>); + + if constexpr (is_lvalue_reference_v<_To>) + return const_cast(__t); + else + return static_cast(__t); + } + + struct _CBegin + { + template + [[nodiscard]] + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_Begin{}(__cust_access::__as_const<_Tp>(__e)))) + requires requires { _Begin{}(__cust_access::__as_const<_Tp>(__e)); } + { + return _Begin{}(__cust_access::__as_const<_Tp>(__e)); + } + }; + + struct _CEnd final + { + template + [[nodiscard]] + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_End{}(__cust_access::__as_const<_Tp>(__e)))) + requires requires { _End{}(__cust_access::__as_const<_Tp>(__e)); } + { + return _End{}(__cust_access::__as_const<_Tp>(__e)); + } + }; + + struct _CRBegin + { + template + [[nodiscard]] + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_RBegin{}(__cust_access::__as_const<_Tp>(__e)))) + requires requires { _RBegin{}(__cust_access::__as_const<_Tp>(__e)); } + { + return _RBegin{}(__cust_access::__as_const<_Tp>(__e)); + } + }; + + struct _CREnd + { + template + [[nodiscard]] + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_REnd{}(__cust_access::__as_const<_Tp>(__e)))) + requires requires { _REnd{}(__cust_access::__as_const<_Tp>(__e)); } + { + return _REnd{}(__cust_access::__as_const<_Tp>(__e)); + } + }; + + struct _CData + { + template + [[nodiscard]] + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_Data{}(__cust_access::__as_const<_Tp>(__e)))) + requires requires { _Data{}(__cust_access::__as_const<_Tp>(__e)); } + { + return _Data{}(__cust_access::__as_const<_Tp>(__e)); + } + }; + + } // namespace __cust_access + + inline namespace __cust + { + inline constexpr __cust_access::_CBegin cbegin{}; + inline constexpr __cust_access::_CEnd cend{}; + inline constexpr __cust_access::_CRBegin crbegin{}; + inline constexpr __cust_access::_CREnd crend{}; + inline constexpr __cust_access::_CData cdata{}; + } + namespace __detail { template -- 2.40.0.335.g9857273be0