[gcc(refs/vendors/ARM/heads/arm-struct-reorg-wip)] libstdc++: Add __cpp_lib_unwrap_ref feature test macro

Tamar Christina tnfchris@gcc.gnu.org
Fri Jul 17 13:01:19 GMT 2020


https://gcc.gnu.org/g:bb54e0b8794dfeea1f59ed9ca6433df1eccb85e9

commit bb54e0b8794dfeea1f59ed9ca6433df1eccb85e9
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Feb 19 15:06:24 2020 +0000

    libstdc++: Add __cpp_lib_unwrap_ref feature test macro
    
    We already defined the traits in <type_traits> as now required by LWG
    3348, but the macro was missing. This adds it.
    
            * include/std/type_traits (__cpp_lib_unwrap_ref): Define (LWG 3348).
            * include/std/version (__cpp_lib_unwrap_ref): Likewise.
            * testsuite/20_util/unwrap_reference/1.cc: Check macro.
            * testsuite/20_util/unwrap_reference/3.cc: New test.

Diff:
---
 libstdc++-v3/ChangeLog                             |  5 ++++
 libstdc++-v3/include/std/type_traits               |  2 ++
 libstdc++-v3/include/std/version                   |  1 +
 .../testsuite/20_util/unwrap_reference/1.cc        |  6 +++++
 .../testsuite/20_util/unwrap_reference/3.cc        | 27 ++++++++++++++++++++++
 5 files changed, 41 insertions(+)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 84e5ea98022..bc4ce773f1e 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,10 @@
 2020-02-19  Jonathan Wakely  <jwakely@redhat.com>
 
+	* include/std/type_traits (__cpp_lib_unwrap_ref): Define (LWG 3348).
+	* include/std/version (__cpp_lib_unwrap_ref): Likewise.
+	* testsuite/20_util/unwrap_reference/1.cc: Check macro.
+	* testsuite/20_util/unwrap_reference/3.cc: New test.
+
 	* include/std/numeric (midpoint(T8, T*)): Do not check for complete
 	type during overload resolution, use static assert instead (LWG 3200).
 	* testsuite/26_numerics/midpoint/pointer.cc: Do not test with
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 684a792d02c..14aa2b37a4f 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -3242,6 +3242,8 @@ template <typename _From, typename _To>
   template<typename _Tp>
     using type_identity_t = typename type_identity<_Tp>::type;
 
+#define __cpp_lib_unwrap_ref 201811L
+
   /// Unwrap a reference_wrapper
   template<typename _Tp>
     struct unwrap_reference { using type = _Tp; };
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index b36b999cb31..e2ccf619d4a 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -178,6 +178,7 @@
 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
 # define __cpp_lib_is_constant_evaluated 201811L
 #endif
+#define __cpp_lib_unwrap_ref 201811L
 
 #if _GLIBCXX_HOSTED
 #define __cpp_lib_bind_front 201907L
diff --git a/libstdc++-v3/testsuite/20_util/unwrap_reference/1.cc b/libstdc++-v3/testsuite/20_util/unwrap_reference/1.cc
index 3a663433911..3496204e4d2 100644
--- a/libstdc++-v3/testsuite/20_util/unwrap_reference/1.cc
+++ b/libstdc++-v3/testsuite/20_util/unwrap_reference/1.cc
@@ -20,6 +20,12 @@
 
 #include <type_traits>
 
+#ifndef __cpp_lib_unwrap_ref
+# error "Feature-test macro for unwrap_reference missing in <type_traits>"
+#elif __cpp_lib_unwrap_ref != 201811L
+# error "Feature-test macro for unwrap_reference has wrong value in <type_traits>"
+#endif
+
 template<typename T, typename U> struct expect_same;
 template<typename T> struct expect_same<T, T> : std::true_type { };
 
diff --git a/libstdc++-v3/testsuite/20_util/unwrap_reference/3.cc b/libstdc++-v3/testsuite/20_util/unwrap_reference/3.cc
new file mode 100644
index 00000000000..3ea9cd18a05
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/unwrap_reference/3.cc
@@ -0,0 +1,27 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <version>
+
+#ifndef __cpp_lib_unwrap_ref
+# error "Feature-test macro for unwrap_reference missing in <version>"
+#elif __cpp_lib_unwrap_ref != 201811L
+# error "Feature-test macro for unwrap_reference has wrong value in <version>"
+#endif


More information about the Libstdc++-cvs mailing list