public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Use new built-ins __remove_cv, __remove_reference etc.
Date: Tue,  4 Oct 2022 17:46:31 +0100	[thread overview]
Message-ID: <20221004164631.558750-1-jwakely@redhat.com> (raw)

Tested powerpc64le-linux. Pushed to trunk.

-- >8 --

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.
---
 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<typename _Tp>
+    struct remove_cv
+    { using type = __remove_cv(_Tp); };
+#else
   template<typename _Tp>
     struct remove_cv
     { using type = _Tp; };
@@ -1522,6 +1527,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     struct remove_cv<const volatile _Tp>
     { using type = _Tp; };
+#endif
 
   /// add_const
   template<typename _Tp>
@@ -1570,17 +1576,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // Reference transformations.
 
   /// remove_reference
+#if __has_builtin(__remove_reference)
   template<typename _Tp>
     struct remove_reference
-    { typedef _Tp   type; };
+    { using type = __remove_reference(_Tp); };
+#else
+  template<typename _Tp>
+    struct remove_reference
+    { using type = _Tp; };
 
   template<typename _Tp>
     struct remove_reference<_Tp&>
-    { typedef _Tp   type; };
+    { using type = _Tp; };
 
   template<typename _Tp>
     struct remove_reference<_Tp&&>
-    { typedef _Tp   type; };
+    { using type = _Tp; };
+#endif
 
   /// add_lvalue_reference
   template<typename _Tp>
@@ -3358,20 +3370,23 @@ template<typename _Ret, typename _Fn, typename... _Args>
    */
 #define __cpp_lib_remove_cvref 201711L
 
+#if __has_builtin(__remove_cvref)
   template<typename _Tp>
     struct remove_cvref
-    : remove_cv<_Tp>
-    { };
+    { using type = __remove_cvref(_Tp); };
+#else
+  template<typename _Tp>
+    struct remove_cvref
+    { using type = typename remove_cv<_Tp>::type; };
 
   template<typename _Tp>
     struct remove_cvref<_Tp&>
-    : remove_cv<_Tp>
-    { };
+    { using type = typename remove_cv<_Tp>::type; };
 
   template<typename _Tp>
     struct remove_cvref<_Tp&&>
-    : remove_cv<_Tp>
-    { };
+    { using type = typename remove_cv<_Tp>::type; };
+#endif
 
   template<typename _Tp>
     using remove_cvref_t = typename remove_cvref<_Tp>::type;
-- 
2.37.3


                 reply	other threads:[~2022-10-04 16:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221004164631.558750-1-jwakely@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).