]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add __cpp_lib_unwrap_ref feature test macro
authorJonathan Wakely <jwakely@redhat.com>
Wed, 19 Feb 2020 15:06:24 +0000 (15:06 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 23 Apr 2020 13:56:21 +0000 (14:56 +0100)
We already defined the traits in <type_traits> as now required by LWG
3348, but the macro was missing. This adds it.

Backport from mainline
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.

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/type_traits
libstdc++-v3/include/std/version
libstdc++-v3/testsuite/20_util/unwrap_reference/1.cc
libstdc++-v3/testsuite/20_util/unwrap_reference/3.cc [new file with mode: 0644]

index 616b154e866c47fedbd8acb8caffa2c9138a3b1c..a5d92e5ae2160710888605c770ba0395dad20cd1 100644 (file)
@@ -1,3 +1,13 @@
+2020-04-23  Jonathan Wakely  <jwakely@redhat.com>
+
+       Backport from mainline
+       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.
+
 2020-04-22  Jonathan Wakely  <jwakely@redhat.com>
 
        * doc/Makefile.am (xml_sources_manual): Add missing XML files.
index 9bad55829ceb6b5dae121603a71a11a08f996ef1..993f7e3153c831988d895a1751b11c44de582b0a 100644 (file)
@@ -3044,6 +3044,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; };
index 9dc7cbbb184b1777154004829a6c78e76e4ec751..39b49371370a28438c0c9e65caf3e6932b8ad0ae 100644 (file)
 # define __cpp_lib_is_constant_evaluated 201811L
 #endif
 #define __cpp_lib_list_remove_return_type 201806L
+#define __cpp_lib_unwrap_ref 201811L
 #endif // C++2a
 #endif // C++17
 #endif // C++14
index 243526725a0f95bde2d028413e81a8796ef4b097..3c04028bb6e490a43824cbcbab087d8a64c92c08 100644 (file)
 
 #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 (file)
index 0000000..3ea9cd1
--- /dev/null
@@ -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