aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/patches/25__tuple.patch
blob: 627c70c2c504fa31999fbb4a8e5f6f3b39a7020e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
diff --git a/include/__tuple/sfinae_helpers.h b/include/__tuple/sfinae_helpers.h
index c7145e0..7db5eeb 100644
--- a/include/__tuple/sfinae_helpers.h
+++ b/include/__tuple/sfinae_helpers.h
@@ -41,7 +41,7 @@ struct __tuple_sfinae_base {
   static auto __do_test(...) -> false_type;
 
   template <class _FromArgs, class _ToArgs>
-  using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
+  using __constructible = decltype(__do_test<is_constructible>(declval<_ToArgs>(), declval<_FromArgs>()));
 };
 
 // __tuple_constructible
@@ -49,11 +49,17 @@ struct __tuple_sfinae_base {
 template <class _Tp,
           class _Up,
           bool = __tuple_like_ext<__libcpp_remove_reference_t<_Tp> >::value,
-          bool = __tuple_like_ext<_Up>::value>
+          bool = __tuple_like_ext<_Up>::value,
+          class = void>
 struct __tuple_constructible : public false_type {};
 
 template <class _Tp, class _Up>
-struct __tuple_constructible<_Tp, _Up, true, true>
+struct __tuple_constructible<
+    _Tp,
+    _Up,
+    true,
+    true,
+    typename enable_if<(tuple_size<typename remove_reference<_Tp>::type>::value == tuple_size<_Up>::value)>::type>
     : public __tuple_sfinae_base::__constructible< typename __make_tuple_types<_Tp>::type,
                                                    typename __make_tuple_types<_Up>::type > {};
 
diff --git a/include/__tuple/tuple_element.h b/include/__tuple/tuple_element.h
index 55b3b47..c6818f2 100644
--- a/include/__tuple/tuple_element.h
+++ b/include/__tuple/tuple_element.h
@@ -60,11 +60,26 @@ __indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
 
 } // namespace __indexer_detail
 
+#    if !defined(__CUDACC__) || !defined(_MSC_VER)
 template <size_t _Idx, class... _Types>
 using __type_pack_element _LIBCPP_NODEBUG = typename decltype(__indexer_detail::__at_index<_Idx>(
     __indexer_detail::__indexer< __tuple_types<_Types...>,
                                  typename __make_tuple_indices<sizeof...(_Types)>::type >{}))::type;
-#  endif
+#    else // !defined(__CUDACC__) || !defined(_MSC_VER)
+template <size_t _Idx, class... _Types>
+struct __y_type_pack_element {
+  using __t1 = typename __make_tuple_indices<sizeof...(_Types)>::type;
+  using __t2 = __indexer_detail::__indexer<__tuple_types<_Types...>, __t1>;
+  using __t3 = decltype(__indexer_detail::__at_index<_Idx>(__t2{}));
+  using __t4 = typename __t3::type;
+};
+
+template <size_t _Idx, class... _Types>
+using __type_pack_element = typename __y_type_pack_element<_Idx, _Types...>::__t4;
+
+#    endif // !defined(__CUDACC__) || !defined(_MSC_VER)
+
+#  endif // __has_builtin(__type_pack_element)
 
 template <size_t _Ip, class... _Types>
 struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > {