aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxxcuda11/patches/45-type-traits.patch
blob: 9e17cc6b21125eac1227608c4eca1e786bcb2f6b (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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
diff --git a/include/__type_traits/enable_if.h b/include/__type_traits/enable_if.h
index 77da962..c1d8896 100644
--- a/include/__type_traits/enable_if.h
+++ b/include/__type_traits/enable_if.h
@@ -32,6 +32,12 @@ template <bool _Bp, class _Tp = void>
 using enable_if_t = typename enable_if<_Bp, _Tp>::type;
 #endif
 
+// CUDA headers use libc++ internals.
+#ifdef __CUDACC__
+template <bool _Cond, class _Ret = void>
+using __lazy_enable_if _LIBCPP_NODEBUG = __enable_if_t<_Cond, _Ret>;
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP___TYPE_TRAITS_ENABLE_IF_H
diff --git a/include/__type_traits/extent.h b/include/__type_traits/extent.h
index bab03fe..8f281b3 100644
--- a/include/__type_traits/extent.h
+++ b/include/__type_traits/extent.h
@@ -19,7 +19,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__array_extent)
+#if __has_builtin(__array_extent) && !defined(__CUDACC__)
 
 template <class _Tp, size_t _Dim = 0>
 struct _LIBCPP_TEMPLATE_VIS extent : integral_constant<size_t, __array_extent(_Tp, _Dim)> {};
diff --git a/include/__type_traits/is_compound.h b/include/__type_traits/is_compound.h
index cd208ce..60cce34 100644
--- a/include/__type_traits/is_compound.h
+++ b/include/__type_traits/is_compound.h
@@ -19,7 +19,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_compound)
+#if __has_builtin(__is_compound) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> {};
diff --git a/include/__type_traits/is_const.h b/include/__type_traits/is_const.h
index 47ef708..0aeceec 100644
--- a/include/__type_traits/is_const.h
+++ b/include/__type_traits/is_const.h
@@ -18,7 +18,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_const)
+#if __has_builtin(__is_const) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> {};
diff --git a/include/__type_traits/is_constant_evaluated.h b/include/__type_traits/is_constant_evaluated.h
index d7af462..713ccfc 100644
--- a/include/__type_traits/is_constant_evaluated.h
+++ b/include/__type_traits/is_constant_evaluated.h
@@ -17,6 +17,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
 #if _LIBCPP_STD_VER >= 20
 _LIBCPP_INLINE_VISIBILITY inline constexpr bool is_constant_evaluated() noexcept {
   return __builtin_is_constant_evaluated();
@@ -26,6 +27,10 @@ _LIBCPP_INLINE_VISIBILITY inline constexpr bool is_constant_evaluated() noexcept
 _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR bool __libcpp_is_constant_evaluated() _NOEXCEPT {
   return __builtin_is_constant_evaluated();
 }
+#else
+inline _LIBCPP_CONSTEXPR
+bool __libcpp_is_constant_evaluated() _NOEXCEPT { return false; }
+#endif // !_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
 
 _LIBCPP_END_NAMESPACE_STD
 
diff --git a/include/__type_traits/is_destructible.h b/include/__type_traits/is_destructible.h
index 3248b07..b3e9bfe 100644
--- a/include/__type_traits/is_destructible.h
+++ b/include/__type_traits/is_destructible.h
@@ -22,7 +22,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_destructible)
+#if __has_builtin(__is_destructible) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> {};
diff --git a/include/__type_traits/is_function.h b/include/__type_traits/is_function.h
index f09f19a..580d1b6 100644
--- a/include/__type_traits/is_function.h
+++ b/include/__type_traits/is_function.h
@@ -20,7 +20,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_function)
+#if __has_builtin(__is_function) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_function : integral_constant<bool, __is_function(_Tp)> {};
diff --git a/include/__type_traits/is_fundamental.h b/include/__type_traits/is_fundamental.h
index 57206e0..417739f 100644
--- a/include/__type_traits/is_fundamental.h
+++ b/include/__type_traits/is_fundamental.h
@@ -20,7 +20,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_fundamental)
+#if __has_builtin(__is_fundamental) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> {};
diff --git a/include/__type_traits/is_integral.h b/include/__type_traits/is_integral.h
index 2696988..a099f7f 100644
--- a/include/__type_traits/is_integral.h
+++ b/include/__type_traits/is_integral.h
@@ -47,7 +47,7 @@ template <>          struct __libcpp_is_integral<__uint128_t>        { enum { va
 #endif
 // clang-format on
 
-#if __has_builtin(__is_integral)
+#if __has_builtin(__is_integral) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> {};
diff --git a/include/__type_traits/is_member_function_pointer.h b/include/__type_traits/is_member_function_pointer.h
index 11c8a00..af2c3e2 100644
--- a/include/__type_traits/is_member_function_pointer.h
+++ b/include/__type_traits/is_member_function_pointer.h
@@ -34,7 +34,7 @@ struct __libcpp_is_member_pointer<_Tp _Up::*> {
   };
 };
 
-#if __has_builtin(__is_member_function_pointer)
+#if __has_builtin(__is_member_function_pointer) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {};
diff --git a/include/__type_traits/is_member_object_pointer.h b/include/__type_traits/is_member_object_pointer.h
index 9141f9d..645488e 100644
--- a/include/__type_traits/is_member_object_pointer.h
+++ b/include/__type_traits/is_member_object_pointer.h
@@ -18,7 +18,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_member_object_pointer)
+#if __has_builtin(__is_member_object_pointer) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {};
diff --git a/include/__type_traits/is_member_pointer.h b/include/__type_traits/is_member_pointer.h
index 4ca01d1..429f2af 100644
--- a/include/__type_traits/is_member_pointer.h
+++ b/include/__type_traits/is_member_pointer.h
@@ -19,7 +19,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_member_pointer)
+#if __has_builtin(__is_member_pointer) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {};
diff --git a/include/__type_traits/is_nothrow_constructible.h b/include/__type_traits/is_nothrow_constructible.h
index 4949062..456c760 100644
--- a/include/__type_traits/is_nothrow_constructible.h
+++ b/include/__type_traits/is_nothrow_constructible.h
@@ -23,7 +23,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 // GCC is disabled due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611
-#if __has_builtin(__is_nothrow_constructible) && !defined(_LIBCPP_COMPILER_GCC)
+#if __has_builtin(__is_nothrow_constructible) && !defined(_LIBCPP_COMPILER_GCC) && !defined(__CUDACC__)
 
 template < class _Tp, class... _Args>
 struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
diff --git a/include/__type_traits/is_object.h b/include/__type_traits/is_object.h
index 5ac1d85..cdfe483 100644
--- a/include/__type_traits/is_object.h
+++ b/include/__type_traits/is_object.h
@@ -22,7 +22,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_object)
+#if __has_builtin(__is_object) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> {};
diff --git a/include/__type_traits/is_pointer.h b/include/__type_traits/is_pointer.h
index 38eb799..5b52619 100644
--- a/include/__type_traits/is_pointer.h
+++ b/include/__type_traits/is_pointer.h
@@ -19,7 +19,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_pointer)
+#if __has_builtin(__is_pointer) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> {};
diff --git a/include/__type_traits/is_reference.h b/include/__type_traits/is_reference.h
index 42853d4..277300b 100644
--- a/include/__type_traits/is_reference.h
+++ b/include/__type_traits/is_reference.h
@@ -18,7 +18,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference) && __has_builtin(__is_reference)
+#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference) && __has_builtin(__is_reference) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {};
diff --git a/include/__type_traits/is_same.h b/include/__type_traits/is_same.h
index 9561b7b..00a191a 100644
--- a/include/__type_traits/is_same.h
+++ b/include/__type_traits/is_same.h
@@ -18,6 +18,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if __has_keyword(__is_same) && !defined(__CUDACC__)
+
 template <class _Tp, class _Up>
 struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> {};
 
@@ -26,6 +28,17 @@ template <class _Tp, class _Up>
 inline constexpr bool is_same_v = __is_same(_Tp, _Up);
 #endif
 
+#else
+
+template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same           : public false_type {};
+template <class _Tp>            struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Up>
+inline constexpr bool is_same_v = is_same<_Tp, _Up>::value;
+#endif
+
+#endif // __is_same
 // _IsSame<T,U> has the same effect as is_same<T,U> but instantiates fewer types:
 // is_same<A,B> and is_same<C,D> are guaranteed to be different types, but
 // _IsSame<A,B> and _IsSame<C,D> are the same type (namely, false_type).
@@ -34,10 +47,23 @@ inline constexpr bool is_same_v = __is_same(_Tp, _Up);
 // (such as in a dependent return type).
 
 template <class _Tp, class _Up>
-using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>;
+using _IsSame = _BoolConstant<
+#if defined(__clang__) && !defined(__CUDACC__)
+    __is_same(_Tp, _Up)
+#else
+    is_same<_Tp, _Up>::value
+#endif
+>;
 
 template <class _Tp, class _Up>
-using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>;
+using _IsNotSame = _BoolConstant<
+#if defined(__clang__) && !defined(__CUDACC__)
+    !__is_same(_Tp, _Up)
+#else
+    !is_same<_Tp, _Up>::value
+#endif
+>;
+
 
 _LIBCPP_END_NAMESPACE_STD
 
diff --git a/include/__type_traits/is_scalar.h b/include/__type_traits/is_scalar.h
index 15f1c71..e6f8e87 100644
--- a/include/__type_traits/is_scalar.h
+++ b/include/__type_traits/is_scalar.h
@@ -23,7 +23,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_scalar)
+#if __has_builtin(__is_scalar) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> {};
diff --git a/include/__type_traits/is_signed.h b/include/__type_traits/is_signed.h
index fd6f93e..2f355e5 100644
--- a/include/__type_traits/is_signed.h
+++ b/include/__type_traits/is_signed.h
@@ -20,7 +20,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_signed)
+#if __has_builtin(__is_signed) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> {};
diff --git a/include/__type_traits/is_trivially_destructible.h b/include/__type_traits/is_trivially_destructible.h
index 5f9652f..e50819f 100644
--- a/include/__type_traits/is_trivially_destructible.h
+++ b/include/__type_traits/is_trivially_destructible.h
@@ -19,7 +19,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_trivially_destructible)
+#if __has_builtin(__is_trivially_destructible) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
diff --git a/include/__type_traits/is_unsigned.h b/include/__type_traits/is_unsigned.h
index 48c5751..44f6152 100644
--- a/include/__type_traits/is_unsigned.h
+++ b/include/__type_traits/is_unsigned.h
@@ -20,7 +20,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_unsigned)
+#if __has_builtin(__is_unsigned) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> {};
diff --git a/include/__type_traits/is_void.h b/include/__type_traits/is_void.h
index 4c27060..69eea76 100644
--- a/include/__type_traits/is_void.h
+++ b/include/__type_traits/is_void.h
@@ -20,7 +20,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_void)
+#if __has_builtin(__is_void) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> {};
diff --git a/include/__type_traits/is_volatile.h b/include/__type_traits/is_volatile.h
index 87960a8..cefadcb 100644
--- a/include/__type_traits/is_volatile.h
+++ b/include/__type_traits/is_volatile.h
@@ -18,7 +18,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__is_volatile)
+#if __has_builtin(__is_volatile) && !defined(__CUDACC__)
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> {};
diff --git a/include/__type_traits/remove_cvref.h b/include/__type_traits/remove_cvref.h
index e8e8745..3ec17b4 100644
--- a/include/__type_traits/remove_cvref.h
+++ b/include/__type_traits/remove_cvref.h
@@ -20,7 +20,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_builtin(__remove_cvref) && !defined(_LIBCPP_COMPILER_GCC)
+#if __has_builtin(__remove_cvref) && !defined(_LIBCPP_COMPILER_GCC) && !defined(__CUDACC__)
 template <class _Tp>
 using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp);
 #else