From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 458FE3858D37; Tue, 4 Oct 2022 16:46:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 458FE3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664901968; bh=6XJTsRWTnSbVxD16JRKqCFzay8s6Isi3MNOfUMpPSdI=; h=From:To:Subject:Date:From; b=A42Rje45c2K1tpF0bmYi6sRlqT123gUVbFoezfNKkN21cz5eGPcm5BtbK2HjXvuoZ YNkj5puJEIObs3xU1qlN0hZdhOJdRkjpYkaGdA1QVgzd82fraY0OT/L0/3bybWJvOq 5XnQey8Zsx78Xrf4RH+eKRQc87IrAol4TM4xf7u0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-3067] libstdc++: Use new built-ins __remove_cv, __remove_reference etc. X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 68ed966793526db02fe96605ba9c0f8bbfd59ef0 X-Git-Newrev: 6ddbbbffbb5759a6c1d56c191364a6bd021f733e Message-Id: <20221004164608.458FE3858D37@sourceware.org> Date: Tue, 4 Oct 2022 16:46:08 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6ddbbbffbb5759a6c1d56c191364a6bd021f733e commit r13-3067-g6ddbbbffbb5759a6c1d56c191364a6bd021f733e Author: Jonathan Wakely Date: Tue Oct 4 13:00:52 2022 +0100 libstdc++: Use new built-ins __remove_cv, __remove_reference etc. libstdc++-v3/ChangeLog: * include/std/type_traits (remove_cv): Use __remove_cv built-in. (remove_reference): Use __remove_reference built-in. (remove_cvref): Use __remove_cvref built-in. Remove inheritance for fallback implementation. Diff: --- libstdc++-v3/include/std/type_traits | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index a015fd95a71..b74565eb521 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1507,6 +1507,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { typedef _Tp type; }; /// remove_cv +#if __has_builtin(__remove_cv) + template + struct remove_cv + { using type = __remove_cv(_Tp); }; +#else template struct remove_cv { using type = _Tp; }; @@ -1522,6 +1527,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct remove_cv { using type = _Tp; }; +#endif /// add_const template @@ -1570,17 +1576,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Reference transformations. /// remove_reference +#if __has_builtin(__remove_reference) template struct remove_reference - { typedef _Tp type; }; + { using type = __remove_reference(_Tp); }; +#else + template + struct remove_reference + { using type = _Tp; }; template struct remove_reference<_Tp&> - { typedef _Tp type; }; + { using type = _Tp; }; template struct remove_reference<_Tp&&> - { typedef _Tp type; }; + { using type = _Tp; }; +#endif /// add_lvalue_reference template @@ -3358,20 +3370,23 @@ template */ #define __cpp_lib_remove_cvref 201711L +#if __has_builtin(__remove_cvref) template struct remove_cvref - : remove_cv<_Tp> - { }; + { using type = __remove_cvref(_Tp); }; +#else + template + struct remove_cvref + { using type = typename remove_cv<_Tp>::type; }; template struct remove_cvref<_Tp&> - : remove_cv<_Tp> - { }; + { using type = typename remove_cv<_Tp>::type; }; template struct remove_cvref<_Tp&&> - : remove_cv<_Tp> - { }; + { using type = typename remove_cv<_Tp>::type; }; +#endif template using remove_cvref_t = typename remove_cvref<_Tp>::type;