From patchwork Thu Sep 7 07:11:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1830719 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=wa9GfHe+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rh9RK0lhvz1yh5 for ; Thu, 7 Sep 2023 17:12:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B210F3851ABB for ; Thu, 7 Sep 2023 07:12:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B210F3851ABB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694070730; bh=/ktRebHPm3oxqcXFi6VDjHQgFQAsXiOMjM1oZuaFtxI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=wa9GfHe+Y41nAI8nNyq+kQEG8AeYfWrMt9HMPPEFwW/eKM86vJ5BaHEPaa1RjcV4I Rkc7Po8MBN1fBeBvfJFIlFib6Pb12Mj9HF+bd5iqt9jR7lKQk8gKgLEv4tvSwZ1PRo OdGjK0r3/FSHVvXQJ3vewh023G8sWODehpbOq9L0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 62B4A3856DC6 for ; Thu, 7 Sep 2023 07:11:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 62B4A3856DC6 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-620-DZzbxtwPPTeqdqk229NnPA-1; Thu, 07 Sep 2023 03:11:42 -0400 X-MC-Unique: DZzbxtwPPTeqdqk229NnPA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 85C181C09CD1; Thu, 7 Sep 2023 07:11:42 +0000 (UTC) Received: from localhost (unknown [10.42.28.200]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EB0940411F; Thu, 7 Sep 2023 07:11:42 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Rename C++20 Customization Point Objects Date: Thu, 7 Sep 2023 08:11:35 +0100 Message-ID: <20230907071141.866877-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Tested x86_64-linux. Pushed to trunk. -- >8 -- This makes the naming of the CPO types and namespaces simpler and more consistent. With this change the string "cust" won't appear in diagnostics related to these CPOs, which avoids confusion about what it means (customization? customer?). Users don't really need to care that these are called "customization point objects", so don't show them the string "cust". Names like "__imove::_IterMove" are preferable to names like "__cust_imove::_IMove" as the former is more obviously related to the public API "ranges::iter_move". Instead of a plethora of inline namespaces for all the different CPO objects, define them all in an inline namespace called _Cpo (which isn't shown to users anyway, unlike the types of those objects). libstdc++-v3/ChangeLog: * include/bits/iterator_concepts.h (ranges::__cust_imove): Rename to ranges::__imove. (_IMove): Rename to _IterMove. (ranges::__cust_iswap): Rename to ranges::__iswap. (ranges::__cust): Rename to ranges::_Cpo. (ranges::__cust_access): Rename to ranges::__access. * include/bits/ranges_base.h (ranges::__cust_access): Rename to ranges::__access. (ranges::__cust): Rename to ranges::_Cpo. * include/std/concepts (ranges::__cust_swap): Rename to ranges::__swap. (ranges::__cust): Rename to ranges::_Cpo. * libsupc++/compare (__cmp_cust): Rename to __compare. (__cmp_algo): Rename to _Cpo. --- libstdc++-v3/include/bits/iterator_concepts.h | 46 ++++---- libstdc++-v3/include/bits/ranges_base.h | 100 +++++++++--------- libstdc++-v3/include/std/concepts | 13 +-- libstdc++-v3/libsupc++/compare | 31 +++--- 4 files changed, 98 insertions(+), 92 deletions(-) diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/include/bits/iterator_concepts.h index e32e94dc9fc..869d52e378b 100644 --- a/libstdc++-v3/include/bits/iterator_concepts.h +++ b/libstdc++-v3/include/bits/iterator_concepts.h @@ -97,7 +97,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace ranges { - namespace __cust_imove + /// @cond undocumented + namespace __imove { void iter_move(); @@ -106,7 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION = (std::__detail::__class_or_enum>) && requires(_Tp&& __t) { iter_move(static_cast<_Tp&&>(__t)); }; - struct _IMove + struct _IterMove { private: template @@ -153,19 +154,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *__e; } }; - } // namespace __cust_imove + } // namespace __imove + /// @endcond - inline namespace __cust - { - inline constexpr __cust_imove::_IMove iter_move{}; - } // inline namespace __cust + inline namespace _Cpo { + inline constexpr __imove::_IterMove iter_move{}; + } } // namespace ranges template<__detail::__dereferenceable _Tp> - requires __detail:: - __can_reference> - using iter_rvalue_reference_t - = ranges::__cust_imove::_IMove::__type<_Tp&>; + requires __detail::__can_reference> + using iter_rvalue_reference_t = ranges::__imove::_IterMove::__type<_Tp&>; template struct incrementable_traits { }; @@ -832,7 +831,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace ranges { - namespace __cust_iswap + /// @cond undocumented + namespace __iswap { template void iter_swap(_It1, _It2) = delete; @@ -873,8 +873,8 @@ namespace ranges *std::declval<_Up>())); else return noexcept(*std::declval<_Tp>() - = __iter_exchange_move(std::declval<_Up>(), - std::declval<_Tp>())); + = __iswap::__iter_exchange_move(std::declval<_Up>(), + std::declval<_Tp>())); } public: @@ -896,15 +896,15 @@ namespace ranges && swappable_with, iter_reference_t<_Up>>) ranges::swap(*__e1, *__e2); else - *__e1 = __iter_exchange_move(__e2, __e1); + *__e1 = __iswap::__iter_exchange_move(__e2, __e1); } }; - } // namespace __cust_iswap + } // namespace __iswap + /// @endcond - inline namespace __cust - { - inline constexpr __cust_iswap::_IterSwap iter_swap{}; - } // inline namespace __cust + inline namespace _Cpo { + inline constexpr __iswap::_IterSwap iter_swap{}; + } } // namespace ranges @@ -960,7 +960,7 @@ namespace ranges inline constexpr unreachable_sentinel_t unreachable_sentinel{}; // This is the namespace for [range.access] CPOs. - namespace ranges::__cust_access + namespace ranges::__access { using std::__detail::__class_or_enum; @@ -1004,14 +1004,14 @@ namespace ranges else return begin(__t); } - } // namespace ranges::__cust_access + } // namespace ranges::__access namespace __detail { // Implementation of std::ranges::iterator_t, without using ranges::begin. template using __range_iter_t - = decltype(ranges::__cust_access::__begin(std::declval<_Tp&>())); + = decltype(ranges::__access::__begin(std::declval<_Tp&>())); } // namespace __detail diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h index 698dac7b7c1..35861755c0b 100644 --- a/libstdc++-v3/include/bits/ranges_base.h +++ b/libstdc++-v3/include/bits/ranges_base.h @@ -87,7 +87,8 @@ namespace ranges } // namespace __detail - namespace __cust_access + // Namespace for helpers for the customization points. + namespace __access { using std::ranges::__detail::__maybe_borrowed_range; using std::__detail::__range_iter_t; @@ -482,18 +483,18 @@ namespace ranges } }; - } // namespace __cust_access + } // namespace __access - inline namespace __cust + inline namespace _Cpo { - inline constexpr __cust_access::_Begin begin{}; - inline constexpr __cust_access::_End end{}; - inline constexpr __cust_access::_RBegin rbegin{}; - inline constexpr __cust_access::_REnd rend{}; - 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 ranges::__access::_Begin begin{}; + inline constexpr ranges::__access::_End end{}; + inline constexpr ranges::__access::_RBegin rbegin{}; + inline constexpr ranges::__access::_REnd rend{}; + inline constexpr ranges::__access::_Size size{}; + inline constexpr ranges::__access::_SSize ssize{}; + inline constexpr ranges::__access::_Empty empty{}; + inline constexpr ranges::__access::_Data data{}; } /// [range.range] The range concept. @@ -624,7 +625,7 @@ namespace ranges = input_range<_Tp> && std::__detail::__constant_iterator>; #endif - namespace __cust_access + namespace __access { #if __cplusplus > 202020L template @@ -659,11 +660,11 @@ namespace ranges constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(std::make_const_iterator - (ranges::begin(__cust_access::__possibly_const_range(__t))))) + (ranges::begin(__access::__possibly_const_range(__t))))) requires requires { std::make_const_iterator - (ranges::begin(__cust_access::__possibly_const_range(__t))); } + (ranges::begin(__access::__possibly_const_range(__t))); } { - auto& __r = __cust_access::__possibly_const_range(__t); + auto& __r = __access::__possibly_const_range(__t); return const_iterator_t(ranges::begin(__r)); } #else @@ -671,10 +672,10 @@ namespace ranges [[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)); } + noexcept(noexcept(_Begin{}(__access::__as_const<_Tp>(__e)))) + requires requires { _Begin{}(__access::__as_const<_Tp>(__e)); } { - return _Begin{}(__cust_access::__as_const<_Tp>(__e)); + return _Begin{}(__access::__as_const<_Tp>(__e)); } #endif }; @@ -687,11 +688,11 @@ namespace ranges constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(std::make_const_sentinel - (ranges::end(__cust_access::__possibly_const_range(__t))))) + (ranges::end(__access::__possibly_const_range(__t))))) requires requires { std::make_const_sentinel - (ranges::end(__cust_access::__possibly_const_range(__t))); } + (ranges::end(__access::__possibly_const_range(__t))); } { - auto& __r = __cust_access::__possibly_const_range(__t); + auto& __r = __access::__possibly_const_range(__t); return const_sentinel_t(ranges::end(__r)); } #else @@ -699,10 +700,10 @@ namespace ranges [[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)); } + noexcept(noexcept(_End{}(__access::__as_const<_Tp>(__e)))) + requires requires { _End{}(__access::__as_const<_Tp>(__e)); } { - return _End{}(__cust_access::__as_const<_Tp>(__e)); + return _End{}(__access::__as_const<_Tp>(__e)); } #endif }; @@ -715,11 +716,11 @@ namespace ranges constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(std::make_const_iterator - (ranges::rbegin(__cust_access::__possibly_const_range(__t))))) + (ranges::rbegin(__access::__possibly_const_range(__t))))) requires requires { std::make_const_iterator - (ranges::rbegin(__cust_access::__possibly_const_range(__t))); } + (ranges::rbegin(__access::__possibly_const_range(__t))); } { - auto& __r = __cust_access::__possibly_const_range(__t); + auto& __r = __access::__possibly_const_range(__t); return const_iterator(ranges::rbegin(__r)); } #else @@ -727,10 +728,10 @@ namespace ranges [[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)); } + noexcept(noexcept(_RBegin{}(__access::__as_const<_Tp>(__e)))) + requires requires { _RBegin{}(__access::__as_const<_Tp>(__e)); } { - return _RBegin{}(__cust_access::__as_const<_Tp>(__e)); + return _RBegin{}(__access::__as_const<_Tp>(__e)); } #endif }; @@ -743,11 +744,11 @@ namespace ranges constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(std::make_const_sentinel - (ranges::rend(__cust_access::__possibly_const_range(__t))))) + (ranges::rend(__access::__possibly_const_range(__t))))) requires requires { std::make_const_sentinel - (ranges::rend(__cust_access::__possibly_const_range(__t))); } + (ranges::rend(__access::__possibly_const_range(__t))); } { - auto& __r = __cust_access::__possibly_const_range(__t); + auto& __r = __access::__possibly_const_range(__t); return const_sentinel(ranges::rend(__r)); } #else @@ -755,10 +756,10 @@ namespace ranges [[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)); } + noexcept(noexcept(_REnd{}(__access::__as_const<_Tp>(__e)))) + requires requires { _REnd{}(__access::__as_const<_Tp>(__e)); } { - return _REnd{}(__cust_access::__as_const<_Tp>(__e)); + return _REnd{}(__access::__as_const<_Tp>(__e)); } #endif }; @@ -770,31 +771,30 @@ namespace ranges [[nodiscard]] constexpr const auto* operator()(_Tp&& __t) const - noexcept(noexcept(ranges::data(__cust_access::__possibly_const_range(__t)))) - requires requires { ranges::data(__cust_access::__possibly_const_range(__t)); } - { return ranges::data(__cust_access::__possibly_const_range(__t)); } + noexcept(noexcept(ranges::data(__access::__possibly_const_range(__t)))) + requires requires { ranges::data(__access::__possibly_const_range(__t)); } + { return ranges::data(__access::__possibly_const_range(__t)); } #else 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)); } + noexcept(noexcept(_Data{}(__access::__as_const<_Tp>(__e)))) + requires requires { _Data{}(__access::__as_const<_Tp>(__e)); } { - return _Data{}(__cust_access::__as_const<_Tp>(__e)); + return _Data{}(__access::__as_const<_Tp>(__e)); } #endif }; + } // namespace __access - } // namespace __cust_access - - inline namespace __cust + inline namespace _Cpo { - 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{}; + inline constexpr ranges::__access::_CBegin cbegin{}; + inline constexpr ranges::__access::_CEnd cend{}; + inline constexpr ranges::__access::_CRBegin crbegin{}; + inline constexpr ranges::__access::_CREnd crend{}; + inline constexpr ranges::__access::_CData cdata{}; } namespace __detail diff --git a/libstdc++-v3/include/std/concepts b/libstdc++-v3/include/std/concepts index d8a05ffab33..d958ab74701 100644 --- a/libstdc++-v3/include/std/concepts +++ b/libstdc++-v3/include/std/concepts @@ -178,7 +178,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace ranges { - namespace __cust_swap + /// @cond undocumented + namespace __swap { template void swap(_Tp&, _Tp&) = delete; @@ -236,12 +237,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION (*this)(__e1[__n], __e2[__n]); } }; - } // namespace __cust_swap + } // namespace __swap + /// @endcond - inline namespace __cust - { - inline constexpr __cust_swap::_Swap swap{}; - } // inline namespace __cust + inline namespace _Cpo { + inline constexpr __swap::_Swap swap{}; + } } // namespace ranges template diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare index 9215f51e94b..84ef31a1ee7 100644 --- a/libstdc++-v3/libsupc++/compare +++ b/libstdc++-v3/libsupc++/compare @@ -566,7 +566,9 @@ namespace std _GLIBCXX_VISIBILITY(default) using is_transparent = void; }; - namespace __cmp_cust + /// @cond undocumented + // Namespace for helpers for the customization points. + namespace __compare { template constexpr weak_ordering @@ -1000,7 +1002,7 @@ namespace std _GLIBCXX_VISIBILITY(default) noexcept(_S_noexcept<_Tp, _Up>()) { if constexpr (floating_point>) - return __cmp_cust::__fp_weak_ordering(__e, __f); + return __compare::__fp_weak_ordering(__e, __f); else if constexpr (__adl_weak<_Tp, _Up>) return weak_ordering(weak_order(static_cast<_Tp&&>(__e), static_cast<_Up&&>(__f))); @@ -1172,27 +1174,29 @@ namespace std _GLIBCXX_VISIBILITY(default) : partial_ordering::unordered; } }; - } // namespace __cmp_cust + } // namespace @endcond // [cmp.alg], comparison algorithms - inline namespace __cmp_alg + + inline namespace _Cpo { - inline constexpr __cmp_cust::_Strong_order strong_order{}; + inline constexpr __compare::_Strong_order strong_order{}; - inline constexpr __cmp_cust::_Weak_order weak_order{}; + inline constexpr __compare::_Weak_order weak_order{}; - inline constexpr __cmp_cust::_Partial_order partial_order{}; + inline constexpr __compare::_Partial_order partial_order{}; - inline constexpr __cmp_cust::_Strong_fallback - compare_strong_order_fallback{}; + inline constexpr __compare::_Strong_fallback + compare_strong_order_fallback{}; - inline constexpr __cmp_cust::_Weak_fallback - compare_weak_order_fallback{}; + inline constexpr __compare::_Weak_fallback + compare_weak_order_fallback{}; - inline constexpr __cmp_cust::_Partial_fallback - compare_partial_order_fallback{}; + inline constexpr __compare::_Partial_fallback + compare_partial_order_fallback{}; } + /// @cond undocumented namespace __detail { // [expos.only.func] synth-three-way @@ -1239,6 +1243,7 @@ namespace std _GLIBCXX_VISIBILITY(default) = decltype(__detail::__synth3way(std::declval<_Tp&>(), std::declval<_Up&>())); } // namespace __detail + /// @endcond #endif // __cpp_lib_three_way_comparison >= 201907L } // namespace std