On 14/06/18 15:00 +0100, Jonathan Wakely wrote:
During the review of P0941R2 in Rapperswil we noticed that SD-6 puts
the macro __cpp_lib_tuple_element_t in <utility>, but it should be in
<tuple>.

        * 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.

Tested x86_64-linux, committed to trunk.

This caused some tests to fail (but not for me, maybe because of
precompiled headers). I'm moving the macro and the alias template back
to <utility>, but keeping the change of the macro value from int to
long (as required by the C++2a working paper).

Tested powerpc64le-linux, committed to trunk.

commit 378a13153d1761f68c5c783d7502761b37e711f5
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Thu Jun 14 19:44:42 2018 +0100

    Partially revert move of std::tuple_element_t to <tuple>
    
    Defining std::tuple_element_t in <utility> makes it available wherever
    std::tuple_element is available.
    
            * include/std/tuple (__cpp_lib_tuple_element_t, tuple_element_t):
            Move back to <utility>.
            * include/std/utility (__cpp_lib_tuple_element_t. tuple_element_t):
            Restore to here.

diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 0f890504889..dd7daf7f1cf 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -1298,13 +1298,6 @@ _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
diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility
index 7bf80de3745..17e7d4cbe7a 100644
--- a/libstdc++-v3/include/std/utility
+++ b/libstdc++-v3/include/std/utility
@@ -135,6 +135,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef typename add_cv<__tuple_element_t<__i, _Tp>>::type type;
     };
 
+#if __cplusplus >= 201402L
+// The standard says this macro and alias template should be in <tuple>
+// but we define them here, to be available when the partial specializations
+// of tuple_element<pair<T,U>> and tuple_element<array<T,N>> are defined.
+#define __cpp_lib_tuple_element_t 201402L
+
+  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

Reply via email to