aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxxmsvc/.yandex_meta/patches/20-compiler-msvc-with-pair.patch
blob: 213977ca6da633f39d66aaf461e371dfbb17c9cf (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
diff --git a/include/__utility/pair.h b/include/__utility/pair.h
index 15532f6..258e653 100644
--- a/include/__utility/pair.h
+++ b/include/__utility/pair.h
@@ -73,85 +73,95 @@ struct _LIBCPP_TEMPLATE_VIS pair
         return *this;
     }
 #else
-    struct _CheckArgs {
-      template <int&...>
-      static constexpr bool __enable_explicit_default() {
-          return is_default_constructible<_T1>::value
-              && is_default_constructible<_T2>::value
-              && !__enable_implicit_default<>();
-      }
-
-      template <int&...>
-      static constexpr bool __enable_implicit_default() {
-          return __is_implicitly_default_constructible<_T1>::value
-              && __is_implicitly_default_constructible<_T2>::value;
-      }
-
-      template <class _U1, class _U2>
-      static constexpr bool __enable_explicit() {
-          return is_constructible<first_type, _U1>::value
-              && is_constructible<second_type, _U2>::value
-              && (!is_convertible<_U1, first_type>::value
-                  || !is_convertible<_U2, second_type>::value);
-      }
-
-      template <class _U1, class _U2>
-      static constexpr bool __enable_implicit() {
-          return is_constructible<first_type, _U1>::value
-              && is_constructible<second_type, _U2>::value
-              && is_convertible<_U1, first_type>::value
-              && is_convertible<_U2, second_type>::value;
-      }
+    template<bool _Dummy = true, int&... _Args>
+    struct _EnableImplicitDefaultConstructor {
+        static constexpr bool value = __is_implicitly_default_constructible<_T1>::value
+            && __is_implicitly_default_constructible<_T2>::value;
     };
 
-    template <bool _MaybeEnable>
-    using _CheckArgsDep _LIBCPP_NODEBUG = typename conditional<
-      _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type;
-
-    struct _CheckTupleLikeConstructor {
-        template <class _Tuple>
-        static constexpr bool __enable_implicit() {
-            return __tuple_convertible<_Tuple, pair>::value;
-        }
-
-        template <class _Tuple>
-        static constexpr bool __enable_explicit() {
-            return __tuple_constructible<_Tuple, pair>::value
-               && !__tuple_convertible<_Tuple, pair>::value;
-        }
-
-        template <class _Tuple>
-        static constexpr bool __enable_assign() {
-            return __tuple_assignable<_Tuple, pair>::value;
-        }
+    template<bool _Dummy = true, int&... _Args>
+    struct _EnableExplicitDefaultConstructor {
+        static constexpr bool value = is_default_constructible<_T1>::value
+            && is_default_constructible<_T2>::value
+            && !_EnableImplicitDefaultConstructor<_Dummy, _Args...>::value;
+    };
+
+    template <class _U1, class _U2, bool _Dummy = true>
+    struct _EnableExplicitConstructor {
+        static constexpr bool value = is_constructible<first_type, _U1>::value
+            && is_constructible<second_type, _U2>::value
+            && (!is_convertible<_U1, first_type>::value
+            || !is_convertible<_U2, second_type>::value);
+    };
+
+    template <class _U1, class _U2, bool _Dummy = true>
+    struct _EnableImplicitConstructor {
+        static constexpr bool value = is_constructible<first_type, _U1>::value
+            && is_constructible<second_type, _U2>::value
+            && is_convertible<_U1, first_type>::value
+            && is_convertible<_U2, second_type>::value;
+    };
+
+    template <class _Tuple, bool _Enable = __tuple_like_with_size<_Tuple, 2>::value
+        && !is_same<typename decay<_Tuple>::type, pair>::value>
+    struct _EnableImplicitTupleLikeConstructor {
+        static constexpr bool value = false;
+    };
+
+    template <class _Tuple, bool _Enable = __tuple_like_with_size<_Tuple, 2>::value
+        && !is_same<typename decay<_Tuple>::type, pair>::value>
+    struct _EnableExplicitTupleLikeConstructor {
+        static constexpr bool value = false;
+    };
+
+    template <class _Tuple, bool _Enable = __tuple_like_with_size<_Tuple, 2>::value
+        && !is_same<typename decay<_Tuple>::type, pair>::value>
+    struct _EnableTupleLikeAssign {
+        static constexpr bool value = false;
+    };
+
+    template <class _Tuple>
+    struct _EnableImplicitTupleLikeConstructor<_Tuple, true> {
+        static constexpr bool value = __tuple_convertible<_Tuple, pair>::value;
+    };
+
+    template <class _Tuple>
+    struct _EnableExplicitTupleLikeConstructor<_Tuple, true> {
+        static constexpr bool value = __tuple_constructible<_Tuple, pair>::value
+            && !__tuple_convertible<_Tuple, pair>::value;
     };
 
     template <class _Tuple>
-    using _CheckTLC _LIBCPP_NODEBUG = typename conditional<
-        __tuple_like_with_size<_Tuple, 2>::value
-            && !is_same<typename decay<_Tuple>::type, pair>::value,
-        _CheckTupleLikeConstructor,
-        __check_tuple_constructor_fail
-    >::type;
+    struct _EnableTupleLikeAssign<_Tuple, true> {
+        static constexpr bool value = __tuple_assignable<_Tuple, pair>::value;
+    };
 
     template<bool _Dummy = true, typename enable_if<
-            _CheckArgsDep<_Dummy>::__enable_explicit_default()
+            _EnableExplicitDefaultConstructor<_Dummy>::value
     >::type* = nullptr>
     explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-    pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
-                      is_nothrow_default_constructible<second_type>::value)
+    pair()
+// danlark@ if you remove this define, MSVC gets into ICE
+#if !defined(_LIBCPP_COMPILER_MSVC)
+    _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
+               is_nothrow_default_constructible<second_type>::value)
+#endif
         : first(), second() {}
 
     template<bool _Dummy = true, typename enable_if<
-            _CheckArgsDep<_Dummy>::__enable_implicit_default()
+             _EnableImplicitDefaultConstructor<_Dummy>::value
     >::type* = nullptr>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-    pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
-                      is_nothrow_default_constructible<second_type>::value)
+    pair()
+// danlark@ if you remove this define, MSVC gets into ICE
+#if !defined(_LIBCPP_COMPILER_MSVC)
+    _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
+               is_nothrow_default_constructible<second_type>::value)
+#endif
         : first(), second() {}
 
     template <bool _Dummy = true, typename enable_if<
-             _CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>()
+             _EnableExplicitConstructor<_T1 const&, _T2 const&, _Dummy>::value
     >::type* = nullptr>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     explicit pair(_T1 const& __t1, _T2 const& __t2)
@@ -159,8 +169,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
                    is_nothrow_copy_constructible<second_type>::value)
         : first(__t1), second(__t2) {}
 
-    template<bool _Dummy = true, typename enable_if<
-            _CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>()
+    template<bool _Dummy = true, bool _Dummy2 = true, typename enable_if<
+            _EnableImplicitConstructor<_T1 const&, _T2 const&, _Dummy>::value
     >::type* = nullptr>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     pair(_T1 const& __t1, _T2 const& __t2)
@@ -174,7 +184,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
 #else
         class _U1, class _U2,
 #endif
-        typename enable_if<_CheckArgs::template __enable_explicit<_U1, _U2>()>::type* = nullptr
+        typename enable_if<_EnableExplicitConstructor<_U1, _U2>::value>::type* = nullptr
     >
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     explicit pair(_U1&& __u1, _U2&& __u2)
@@ -182,13 +192,13 @@ struct _LIBCPP_TEMPLATE_VIS pair
                     is_nothrow_constructible<second_type, _U2>::value))
         : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
 
-    template <
+    template<
 #if _LIBCPP_STD_VER > 20 // http://wg21.link/P1951
         class _U1 = _T1, class _U2 = _T2,
 #else
         class _U1, class _U2,
 #endif
-        typename enable_if<_CheckArgs::template __enable_implicit<_U1, _U2>()>::type* = nullptr
+        bool _Dummy = true, typename enable_if<_EnableImplicitConstructor<_U1, _U2, _Dummy>::value>::type* = nullptr
     >
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     pair(_U1&& __u1, _U2&& __u2)
@@ -197,7 +207,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
         : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
 
     template<class _U1, class _U2, typename enable_if<
-            _CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>()
+            _EnableExplicitConstructor<_U1 const&, _U2 const&>::value
     >::type* = nullptr>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     explicit pair(pair<_U1, _U2> const& __p)
@@ -205,8 +215,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
                     is_nothrow_constructible<second_type, _U2 const&>::value))
         : first(__p.first), second(__p.second) {}
 
-    template<class _U1, class _U2, typename enable_if<
-            _CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>()
+    template<class _U1, class _U2, bool _Dummy = true, typename enable_if<
+            _EnableImplicitConstructor<_U1 const&, _U2 const&, _Dummy>::value
     >::type* = nullptr>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     pair(pair<_U1, _U2> const& __p)
@@ -215,7 +225,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
         : first(__p.first), second(__p.second) {}
 
     template<class _U1, class _U2, typename enable_if<
-            _CheckArgs::template __enable_explicit<_U1, _U2>()
+            _EnableExplicitConstructor<_U1, _U2>::value
     >::type* = nullptr>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     explicit pair(pair<_U1, _U2>&&__p)
@@ -223,8 +233,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
                     is_nothrow_constructible<second_type, _U2&&>::value))
         : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
 
-    template<class _U1, class _U2, typename enable_if<
-            _CheckArgs::template __enable_implicit<_U1, _U2>()
+    template<class _U1, class _U2, bool _Dummy = true, typename enable_if<
+            _EnableImplicitConstructor<_U1, _U2>::value
     >::type* = nullptr>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     pair(pair<_U1, _U2>&& __p)
@@ -233,15 +243,15 @@ struct _LIBCPP_TEMPLATE_VIS pair
         : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
 
     template<class _Tuple, typename enable_if<
-            _CheckTLC<_Tuple>::template __enable_explicit<_Tuple>()
+            _EnableExplicitTupleLikeConstructor<_Tuple>::value
     >::type* = nullptr>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     explicit pair(_Tuple&& __p)
         : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
           second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
 
-    template<class _Tuple, typename enable_if<
-            _CheckTLC<_Tuple>::template __enable_implicit<_Tuple>()
+    template<class _Tuple, bool _Dummy = true, typename enable_if<
+            _EnableImplicitTupleLikeConstructor<_Tuple>::value
     >::type* = nullptr>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     pair(_Tuple&& __p)
@@ -284,8 +294,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
         return *this;
     }
 
-    template <class _Tuple, typename enable_if<
-            _CheckTLC<_Tuple>::template __enable_assign<_Tuple>()
+    template <class _Tuple, bool _Dummy = true, typename enable_if<
+            _EnableTupleLikeAssign<_Tuple>::value
      >::type* = nullptr>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     pair& operator=(_Tuple&& __p) {
@@ -309,9 +319,9 @@ private:
 #ifndef _LIBCPP_CXX03_LANG
     template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-    pair(piecewise_construct_t,
-         tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
-         __tuple_indices<_I1...>, __tuple_indices<_I2...>);
+        pair(piecewise_construct_t,
+             tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
+             __tuple_indices<_I1...>, __tuple_indices<_I2...>);
 #endif
 };