This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/78939] [C++17] <tuple> interferes with structured binding from struct


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78939

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
No, no change. I think we need to change the tuple_size<cv T> specializations
to be incomplete when tuple_size<T> is incomplete, even though that appears to
contradict the changes made by lwg 2770.

--- a/libstdc++-v3/include/std/utility
+++ b/libstdc++-v3/include/std/utility
@@ -88,24 +88,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct tuple_size;

   // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 2313. tuple_size should always derive from integral_constant<size_t, N>
   // 2770. tuple_size<const T> specialization is not SFINAE compatible
-  template<typename _Tp, typename = void>
-    struct __tuple_size_cv_impl { };

-  template<typename _Tp>
-    struct __tuple_size_cv_impl<_Tp,
__void_t<decltype(tuple_size<_Tp>::value)>>
-    : integral_constant<size_t, tuple_size<_Tp>::value> { };
+  template<typename _Tp, size_t = tuple_size<_Tp>::value>
+    using __enable_if_has_tuple_size = _Tp;

-  // _GLIBCXX_RESOLVE_LIB_DEFECTS
-  // 2313. tuple_size should always derive from integral_constant<size_t, N>
   template<typename _Tp>
-    struct tuple_size<const _Tp> : __tuple_size_cv_impl<_Tp> { };
+    struct tuple_size<const __enable_if_has_tuple_size<_Tp>>
+    : public tuple_size<_Tp> { };

   template<typename _Tp>
-    struct tuple_size<volatile _Tp> : __tuple_size_cv_impl<_Tp> { };
+    struct tuple_size<volatile __enable_if_has_tuple_size<_Tp>>
+    : public tuple_size<_Tp> { };

   template<typename _Tp>
-    struct tuple_size<const volatile _Tp> : __tuple_size_cv_impl<_Tp> { };
+    struct tuple_size<const volatile __enable_if_has_tuple_size<_Tp>>
+    : public tuple_size<_Tp> { };

   /// Gives the type of the ith element of a given tuple type.
   template<std::size_t __i, typename _Tp>

But this also affects C++11 mode, so I'm still trying to understand all the
consequences of such a change. At the least, some tests need changing:


FAIL: 20_util/pair/astuple/astuple.cc (test for excess errors)
FAIL: 20_util/tuple/cv_tuple_size.cc (test for excess errors)
UNRESOLVED: 20_util/tuple/cv_tuple_size.cc compilation failed to produce
executable
FAIL: 20_util/tuple/tuple_size.cc (test for excess errors)
FAIL: 23_containers/array/tuple_interface/tuple_size.cc (test for excess
errors)

These all fail for the same reason, and I think it's a FE bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]