public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r12-566] libstdc++: Fix definition of std::remove_cvref_t
Date: Thu,  6 May 2021 12:42:12 +0000 (GMT)	[thread overview]
Message-ID: <20210506124212.07774384640F@sourceware.org> (raw)

https://gcc.gnu.org/g:0e79e63026e43ad0577812ffb405dac8fa88af5b

commit r12-566-g0e79e63026e43ad0577812ffb405dac8fa88af5b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu May 6 13:40:53 2021 +0100

    libstdc++: Fix definition of std::remove_cvref_t
    
    I originally defined std::remove_cvref_t in terms of the internal
    __remove_cvref_t trait, to avoid instantiating the remove_cvref class
    template. However, as described in P1715R0 that is observable by users
    and is thus non-conforming.
    
    This defines remove_cvref_t as specified in the standard.
    
    libstdc++-v3/ChangeLog:
    
            * include/std/type_traits (remove_cvref_t): Define in terms of
            remove_cvref.
            * testsuite/20_util/remove_cvref/value.cc: Check alias.

Diff:
---
 libstdc++-v3/include/std/type_traits                 | 17 +++++++++++++----
 libstdc++-v3/testsuite/20_util/remove_cvref/value.cc |  7 +++++++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 1f8b57b04a0..eaf06fcb036 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -3223,12 +3223,21 @@ template <typename _From, typename _To>
   /// Remove references and cv-qualifiers.
   template<typename _Tp>
     struct remove_cvref
-    {
-      using type = __remove_cvref_t<_Tp>;
-    };
+    : remove_cv<_Tp>
+    { };
+
+  template<typename _Tp>
+    struct remove_cvref<_Tp&>
+    : remove_cv<_Tp>
+    { };
+
+  template<typename _Tp>
+    struct remove_cvref<_Tp&&>
+    : remove_cv<_Tp>
+    { };
 
   template<typename _Tp>
-    using remove_cvref_t = __remove_cvref_t<_Tp>;
+    using remove_cvref_t = typename remove_cvref<_Tp>::type;
 
 #define __cpp_lib_type_identity 201806L
   /// Identity metafunction.
diff --git a/libstdc++-v3/testsuite/20_util/remove_cvref/value.cc b/libstdc++-v3/testsuite/20_util/remove_cvref/value.cc
index d4a28422977..a4f50d433dc 100644
--- a/libstdc++-v3/testsuite/20_util/remove_cvref/value.cc
+++ b/libstdc++-v3/testsuite/20_util/remove_cvref/value.cc
@@ -48,3 +48,10 @@ void test01()
   static_assert(is_same<typename remove_cvref<const int(&)()>::type,
 			const int()>::value, "");
 }
+
+// Declare using nested name of class template
+template<typename T> T func(typename std::remove_cvref<T>::type);
+// Define using alias
+template<typename T> T func(std::remove_cvref_t<T> t) { return t; }
+// Call must not be ambiguous
+int i = func<int>(1);


                 reply	other threads:[~2021-05-06 12:42 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=20210506124212.07774384640F@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@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).