public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-566] libstdc++: Fix definition of std::remove_cvref_t
@ 2021-05-06 12:42 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-05-06 12:42 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-06 12:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 12:42 [gcc r12-566] libstdc++: Fix definition of std::remove_cvref_t Jonathan Wakely
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).