Define __cpp_lib_tuple_element_t in <tuple> not <utility>
authorJonathan Wakely <jwakely@redhat.com>
Thu, 14 Jun 2018 14:01:29 +0000 (15:01 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 14 Jun 2018 14:01:29 +0000 (15:01 +0100)
* include/std/tuple (__cpp_lib_tuple_element_t): Move feature test
macro from <utility> and change type to long.
* include/std/utility (__cpp_lib_tuple_element_t): Remove.
* testsuite/20_util/tuple/tuple_element_t.cc: Check for feature test
macro.

From-SVN: r261596

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/tuple
libstdc++-v3/include/std/utility
libstdc++-v3/testsuite/20_util/tuple/tuple_element_t.cc

index 738b7acc8f29a448225afe3f54a151ca9d26dea6..5f612239bb8f89fde25614084ae2c608595af8f7 100644 (file)
@@ -1,5 +1,11 @@
 2018-06-14  Jonathan Wakely  <jwakely@redhat.com>
 
+       * include/std/tuple (__cpp_lib_tuple_element_t): Move feature test
+       macro from <utility> and change type to long.
+       * include/std/utility (__cpp_lib_tuple_element_t): Remove.
+       * testsuite/20_util/tuple/tuple_element_t.cc: Check for feature test
+       macro.
+
        P0935R0 Eradicating unnecessarily explicit default constructors
        * include/bits/random.h (uniform_real_distribution::param_type)
        (normal_distribution::param_type, lognormal_distribution::param_type)
index 16f69220abbed7fa78c5513c400c435a12e9efd3..0f890504889ca076e41848b95a50ba760a68aa83 100644 (file)
@@ -1298,6 +1298,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          "tuple index is in range");
     };
 
+#if __cplusplus >= 201402L
+#define __cpp_lib_tuple_element_t 201402L
+
+  template<size_t __i, typename _Tp>
+    using tuple_element_t = typename tuple_element<__i, _Tp>::type;
+#endif
+
   template<std::size_t __i, typename _Head, typename... _Tail>
     constexpr _Head&
     __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
@@ -1338,7 +1345,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return std::forward<const __element_type&&>(std::get<__i>(__t));
     }
 
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
 
 #define __cpp_lib_tuples_by_type 201304
 
@@ -1470,6 +1477,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // 2275. Why is forward_as_tuple not constexpr?
+  /// std::forward_as_tuple
   template<typename... _Elements>
     constexpr tuple<_Elements&&...>
     forward_as_tuple(_Elements&&... __args) noexcept
index c9695006ff14e84a1272f780ea832cc5a913aa64..7bf80de37459034d02137b854da2cf5f7bcd3de9 100644 (file)
@@ -135,13 +135,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef typename add_cv<__tuple_element_t<__i, _Tp>>::type type;
     };
 
-#if __cplusplus > 201103L
-#define __cpp_lib_tuple_element_t 201402
-
-  template<std::size_t __i, typename _Tp>
-    using tuple_element_t = typename tuple_element<__i, _Tp>::type;
-#endif
-
   // Various functions which give std::pair a tuple-like interface.
 
   /// Partial specialization for std::pair
index 8f7aa58d34e1df4b000f0ba8ed6ead15ac8596cf..6b1b7a54251b5c75ca67722f861a1195e4b80fba 100644 (file)
 
 #include <tuple>
 
+#ifndef __cpp_lib_tuple_element_t
+# error "Feature-test macro for tuple_element_t missing"
+#elif __cpp_lib_tuple_element_t != 201402
+# error "Feature-test macro for tuple_element_t has wrong value"
+#endif
+
 using namespace std;
 
 struct foo