]>
Commit | Line | Data |
---|---|---|
c0ffa2ba | 1 | // C++11 <type_traits> -*- C++ -*- |
af13a7a6 | 2 | |
8d9254fc | 3 | // Copyright (C) 2007-2020 Free Software Foundation, Inc. |
af13a7a6 BK |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
af13a7a6 BK |
9 | // any later version. |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
748086b7 JJ |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the Free Software Foundation. | |
19 | ||
20 | // You should have received a copy of the GNU General Public License and | |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
af13a7a6 BK |
24 | |
25 | /** @file include/type_traits | |
26 | * This is a Standard C++ Library header. | |
27 | */ | |
28 | ||
4514bed6 BK |
29 | #ifndef _GLIBCXX_TYPE_TRAITS |
30 | #define _GLIBCXX_TYPE_TRAITS 1 | |
af13a7a6 BK |
31 | |
32 | #pragma GCC system_header | |
33 | ||
734f5023 | 34 | #if __cplusplus < 201103L |
ab65a4c7 | 35 | # include <bits/c++0x_warning.h> |
57317d2a | 36 | #else |
af13a7a6 | 37 | |
8fc81078 | 38 | #include <bits/c++config.h> |
e133ace8 | 39 | |
21e2806a JW |
40 | namespace std _GLIBCXX_VISIBILITY(default) |
41 | { | |
42 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
43 | ||
8e32aa11 | 44 | /** |
c0ffa2ba | 45 | * @defgroup metaprogramming Metaprogramming |
13901e4b JW |
46 | * @ingroup utilities |
47 | * | |
48 | * Template utilities for compile-time introspection and modification, | |
49 | * including type classification traits, type property inspection traits | |
50 | * and type transformation traits. | |
51 | * | |
5b9daa7e BK |
52 | * @{ |
53 | */ | |
ac65b7d2 DK |
54 | |
55 | /// integral_constant | |
56 | template<typename _Tp, _Tp __v> | |
57 | struct integral_constant | |
58 | { | |
59 | static constexpr _Tp value = __v; | |
60 | typedef _Tp value_type; | |
61 | typedef integral_constant<_Tp, __v> type; | |
352111c5 | 62 | constexpr operator value_type() const noexcept { return value; } |
db113eda | 63 | #if __cplusplus > 201103L |
a15f7cb8 ESR |
64 | |
65 | #define __cpp_lib_integral_constant_callable 201304 | |
66 | ||
352111c5 | 67 | constexpr value_type operator()() const noexcept { return value; } |
db113eda | 68 | #endif |
ac65b7d2 | 69 | }; |
33ac58d5 | 70 | |
c0ffa2ba BK |
71 | template<typename _Tp, _Tp __v> |
72 | constexpr _Tp integral_constant<_Tp, __v>::value; | |
73 | ||
13901e4b | 74 | /// The type used as a compile-time boolean with true value. |
ac65b7d2 DK |
75 | typedef integral_constant<bool, true> true_type; |
76 | ||
13901e4b | 77 | /// The type used as a compile-time boolean with false value. |
ac65b7d2 DK |
78 | typedef integral_constant<bool, false> false_type; |
79 | ||
f6b640be JW |
80 | template<bool __v> |
81 | using __bool_constant = integral_constant<bool, __v>; | |
82 | ||
46ba1281 | 83 | #if __cplusplus > 201402L |
f9badf71 | 84 | # define __cpp_lib_bool_constant 201505 |
46ba1281 JW |
85 | template<bool __v> |
86 | using bool_constant = integral_constant<bool, __v>; | |
87 | #endif | |
88 | ||
123c516a | 89 | // Meta programming helper types. |
53dc5044 | 90 | |
123c516a PC |
91 | template<bool, typename, typename> |
92 | struct conditional; | |
53dc5044 | 93 | |
608a080c | 94 | template <typename _Type> |
0d67cd38 JW |
95 | struct __type_identity |
96 | { using type = _Type; }; | |
97 | ||
98 | template<typename _Tp> | |
99 | using __type_identity_t = typename __type_identity<_Tp>::type; | |
608a080c | 100 | |
dd7b175e | 101 | template<typename...> |
123c516a PC |
102 | struct __or_; |
103 | ||
ac65b7d2 DK |
104 | template<> |
105 | struct __or_<> | |
106 | : public false_type | |
107 | { }; | |
108 | ||
dd7b175e PC |
109 | template<typename _B1> |
110 | struct __or_<_B1> | |
111 | : public _B1 | |
112 | { }; | |
113 | ||
123c516a PC |
114 | template<typename _B1, typename _B2> |
115 | struct __or_<_B1, _B2> | |
116 | : public conditional<_B1::value, _B1, _B2>::type | |
117 | { }; | |
118 | ||
119 | template<typename _B1, typename _B2, typename _B3, typename... _Bn> | |
120 | struct __or_<_B1, _B2, _B3, _Bn...> | |
121 | : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type | |
122 | { }; | |
53dc5044 | 123 | |
dd7b175e | 124 | template<typename...> |
123c516a | 125 | struct __and_; |
53dc5044 | 126 | |
ac65b7d2 DK |
127 | template<> |
128 | struct __and_<> | |
129 | : public true_type | |
130 | { }; | |
131 | ||
dd7b175e PC |
132 | template<typename _B1> |
133 | struct __and_<_B1> | |
134 | : public _B1 | |
135 | { }; | |
136 | ||
123c516a PC |
137 | template<typename _B1, typename _B2> |
138 | struct __and_<_B1, _B2> | |
139 | : public conditional<_B1::value, _B2, _B1>::type | |
140 | { }; | |
141 | ||
142 | template<typename _B1, typename _B2, typename _B3, typename... _Bn> | |
143 | struct __and_<_B1, _B2, _B3, _Bn...> | |
144 | : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type | |
145 | { }; | |
146 | ||
147 | template<typename _Pp> | |
148 | struct __not_ | |
4b9840f2 | 149 | : public __bool_constant<!bool(_Pp::value)> |
123c516a PC |
150 | { }; |
151 | ||
4b9840f2 | 152 | #if __cplusplus >= 201703L |
c3a6648b | 153 | |
b655b8fc JW |
154 | template<typename... _Bn> |
155 | inline constexpr bool __or_v = __or_<_Bn...>::value; | |
156 | template<typename... _Bn> | |
157 | inline constexpr bool __and_v = __and_<_Bn...>::value; | |
158 | ||
068c8ac1 | 159 | #define __cpp_lib_logical_traits 201510 |
c3a6648b VV |
160 | |
161 | template<typename... _Bn> | |
162 | struct conjunction | |
163 | : __and_<_Bn...> | |
164 | { }; | |
165 | ||
166 | template<typename... _Bn> | |
167 | struct disjunction | |
168 | : __or_<_Bn...> | |
169 | { }; | |
170 | ||
171 | template<typename _Pp> | |
172 | struct negation | |
173 | : __not_<_Pp> | |
174 | { }; | |
137422c8 VV |
175 | |
176 | template<typename... _Bn> | |
4b9840f2 | 177 | inline constexpr bool conjunction_v = conjunction<_Bn...>::value; |
42183d03 | 178 | |
137422c8 | 179 | template<typename... _Bn> |
4b9840f2 | 180 | inline constexpr bool disjunction_v = disjunction<_Bn...>::value; |
42183d03 | 181 | |
137422c8 | 182 | template<typename _Pp> |
4b9840f2 | 183 | inline constexpr bool negation_v = negation<_Pp>::value; |
137422c8 | 184 | |
4b9840f2 | 185 | #endif // C++17 |
c3a6648b | 186 | |
608a080c AP |
187 | // Forward declarations |
188 | template<typename> | |
189 | struct is_reference; | |
190 | template<typename> | |
191 | struct is_function; | |
192 | template<typename> | |
193 | struct is_void; | |
194 | template<typename> | |
195 | struct __is_array_unknown_bounds; | |
196 | ||
197 | // Helper functions that return false_type for incomplete classes, | |
198 | // incomplete unions and arrays of known bound from those. | |
199 | ||
200 | template <typename _T, size_t = sizeof(_T)> | |
201 | constexpr true_type __is_complete_or_unbounded(__type_identity<_T>) | |
202 | { return {}; } | |
203 | ||
204 | template <typename _TypeIdentity, | |
205 | typename _NestedType = typename _TypeIdentity::type> | |
206 | constexpr typename __or_< | |
207 | is_reference<_NestedType>, | |
208 | is_function<_NestedType>, | |
209 | is_void<_NestedType>, | |
210 | __is_array_unknown_bounds<_NestedType> | |
211 | >::type __is_complete_or_unbounded(_TypeIdentity) | |
212 | { return {}; } | |
213 | ||
b3618b71 DK |
214 | // For several sfinae-friendly trait implementations we transport both the |
215 | // result information (as the member type) and the failure information (no | |
216 | // member type). This is very similar to std::enable_if, but we cannot use | |
217 | // them, because we need to derive from them as an implementation detail. | |
218 | ||
219 | template<typename _Tp> | |
220 | struct __success_type | |
221 | { typedef _Tp type; }; | |
222 | ||
223 | struct __failure_type | |
224 | { }; | |
225 | ||
53dc5044 PC |
226 | template<typename> |
227 | struct remove_cv; | |
228 | ||
391d5d2e JW |
229 | // __remove_cv_t (std::remove_cv_t for C++11). |
230 | template<typename _Tp> | |
231 | using __remove_cv_t = typename remove_cv<_Tp>::type; | |
232 | ||
72459cfd JW |
233 | template<typename> |
234 | struct is_const; | |
235 | ||
236 | // Primary type categories. | |
237 | ||
53dc5044 PC |
238 | template<typename> |
239 | struct __is_void_helper | |
240 | : public false_type { }; | |
53dc5044 | 241 | |
123c516a PC |
242 | template<> |
243 | struct __is_void_helper<void> | |
244 | : public true_type { }; | |
53dc5044 PC |
245 | |
246 | /// is_void | |
247 | template<typename _Tp> | |
248 | struct is_void | |
391d5d2e | 249 | : public __is_void_helper<__remove_cv_t<_Tp>>::type |
53dc5044 PC |
250 | { }; |
251 | ||
252 | template<typename> | |
253 | struct __is_integral_helper | |
254 | : public false_type { }; | |
123c516a PC |
255 | |
256 | template<> | |
257 | struct __is_integral_helper<bool> | |
258 | : public true_type { }; | |
33ac58d5 | 259 | |
123c516a PC |
260 | template<> |
261 | struct __is_integral_helper<char> | |
262 | : public true_type { }; | |
263 | ||
264 | template<> | |
265 | struct __is_integral_helper<signed char> | |
266 | : public true_type { }; | |
267 | ||
268 | template<> | |
269 | struct __is_integral_helper<unsigned char> | |
270 | : public true_type { }; | |
271 | ||
53dc5044 | 272 | #ifdef _GLIBCXX_USE_WCHAR_T |
123c516a PC |
273 | template<> |
274 | struct __is_integral_helper<wchar_t> | |
275 | : public true_type { }; | |
53dc5044 | 276 | #endif |
123c516a | 277 | |
c124af93 TH |
278 | #ifdef _GLIBCXX_USE_CHAR8_T |
279 | template<> | |
280 | struct __is_integral_helper<char8_t> | |
281 | : public true_type { }; | |
282 | #endif | |
283 | ||
123c516a PC |
284 | template<> |
285 | struct __is_integral_helper<char16_t> | |
286 | : public true_type { }; | |
287 | ||
288 | template<> | |
289 | struct __is_integral_helper<char32_t> | |
290 | : public true_type { }; | |
291 | ||
292 | template<> | |
293 | struct __is_integral_helper<short> | |
294 | : public true_type { }; | |
295 | ||
296 | template<> | |
297 | struct __is_integral_helper<unsigned short> | |
298 | : public true_type { }; | |
299 | ||
300 | template<> | |
301 | struct __is_integral_helper<int> | |
302 | : public true_type { }; | |
303 | ||
304 | template<> | |
305 | struct __is_integral_helper<unsigned int> | |
306 | : public true_type { }; | |
307 | ||
308 | template<> | |
309 | struct __is_integral_helper<long> | |
310 | : public true_type { }; | |
311 | ||
312 | template<> | |
313 | struct __is_integral_helper<unsigned long> | |
314 | : public true_type { }; | |
315 | ||
316 | template<> | |
317 | struct __is_integral_helper<long long> | |
318 | : public true_type { }; | |
319 | ||
320 | template<> | |
321 | struct __is_integral_helper<unsigned long long> | |
322 | : public true_type { }; | |
53dc5044 | 323 | |
78a7c317 DD |
324 | // Conditionalizing on __STRICT_ANSI__ here will break any port that |
325 | // uses one of these types for size_t. | |
326 | #if defined(__GLIBCXX_TYPE_INT_N_0) | |
6d585f01 | 327 | template<> |
78a7c317 | 328 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0> |
6d585f01 PC |
329 | : public true_type { }; |
330 | ||
331 | template<> | |
78a7c317 DD |
332 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0> |
333 | : public true_type { }; | |
334 | #endif | |
335 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
336 | template<> | |
337 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1> | |
338 | : public true_type { }; | |
339 | ||
340 | template<> | |
341 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1> | |
342 | : public true_type { }; | |
343 | #endif | |
344 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
345 | template<> | |
346 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2> | |
347 | : public true_type { }; | |
348 | ||
349 | template<> | |
350 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2> | |
351 | : public true_type { }; | |
352 | #endif | |
353 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
354 | template<> | |
355 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3> | |
356 | : public true_type { }; | |
357 | ||
358 | template<> | |
359 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3> | |
6d585f01 PC |
360 | : public true_type { }; |
361 | #endif | |
362 | ||
53dc5044 PC |
363 | /// is_integral |
364 | template<typename _Tp> | |
365 | struct is_integral | |
391d5d2e | 366 | : public __is_integral_helper<__remove_cv_t<_Tp>>::type |
53dc5044 PC |
367 | { }; |
368 | ||
369 | template<typename> | |
370 | struct __is_floating_point_helper | |
371 | : public false_type { }; | |
123c516a PC |
372 | |
373 | template<> | |
374 | struct __is_floating_point_helper<float> | |
375 | : public true_type { }; | |
376 | ||
377 | template<> | |
378 | struct __is_floating_point_helper<double> | |
379 | : public true_type { }; | |
380 | ||
381 | template<> | |
382 | struct __is_floating_point_helper<long double> | |
383 | : public true_type { }; | |
53dc5044 | 384 | |
6d585f01 PC |
385 | #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) |
386 | template<> | |
387 | struct __is_floating_point_helper<__float128> | |
388 | : public true_type { }; | |
389 | #endif | |
390 | ||
53dc5044 PC |
391 | /// is_floating_point |
392 | template<typename _Tp> | |
393 | struct is_floating_point | |
391d5d2e | 394 | : public __is_floating_point_helper<__remove_cv_t<_Tp>>::type |
53dc5044 PC |
395 | { }; |
396 | ||
397 | /// is_array | |
398 | template<typename> | |
399 | struct is_array | |
400 | : public false_type { }; | |
401 | ||
402 | template<typename _Tp, std::size_t _Size> | |
403 | struct is_array<_Tp[_Size]> | |
404 | : public true_type { }; | |
405 | ||
406 | template<typename _Tp> | |
407 | struct is_array<_Tp[]> | |
408 | : public true_type { }; | |
409 | ||
410 | template<typename> | |
411 | struct __is_pointer_helper | |
412 | : public false_type { }; | |
123c516a PC |
413 | |
414 | template<typename _Tp> | |
415 | struct __is_pointer_helper<_Tp*> | |
416 | : public true_type { }; | |
53dc5044 PC |
417 | |
418 | /// is_pointer | |
419 | template<typename _Tp> | |
420 | struct is_pointer | |
391d5d2e | 421 | : public __is_pointer_helper<__remove_cv_t<_Tp>>::type |
53dc5044 PC |
422 | { }; |
423 | ||
123c516a PC |
424 | /// is_lvalue_reference |
425 | template<typename> | |
426 | struct is_lvalue_reference | |
427 | : public false_type { }; | |
428 | ||
53dc5044 | 429 | template<typename _Tp> |
123c516a PC |
430 | struct is_lvalue_reference<_Tp&> |
431 | : public true_type { }; | |
432 | ||
433 | /// is_rvalue_reference | |
434 | template<typename> | |
435 | struct is_rvalue_reference | |
436 | : public false_type { }; | |
53dc5044 | 437 | |
53dc5044 | 438 | template<typename _Tp> |
123c516a PC |
439 | struct is_rvalue_reference<_Tp&&> |
440 | : public true_type { }; | |
441 | ||
53dc5044 PC |
442 | template<typename> |
443 | struct __is_member_object_pointer_helper | |
444 | : public false_type { }; | |
123c516a PC |
445 | |
446 | template<typename _Tp, typename _Cp> | |
447 | struct __is_member_object_pointer_helper<_Tp _Cp::*> | |
c01f9216 | 448 | : public __not_<is_function<_Tp>>::type { }; |
53dc5044 PC |
449 | |
450 | /// is_member_object_pointer | |
451 | template<typename _Tp> | |
452 | struct is_member_object_pointer | |
391d5d2e | 453 | : public __is_member_object_pointer_helper<__remove_cv_t<_Tp>>::type |
53dc5044 PC |
454 | { }; |
455 | ||
456 | template<typename> | |
457 | struct __is_member_function_pointer_helper | |
458 | : public false_type { }; | |
123c516a PC |
459 | |
460 | template<typename _Tp, typename _Cp> | |
461 | struct __is_member_function_pointer_helper<_Tp _Cp::*> | |
c01f9216 | 462 | : public is_function<_Tp>::type { }; |
53dc5044 PC |
463 | |
464 | /// is_member_function_pointer | |
465 | template<typename _Tp> | |
466 | struct is_member_function_pointer | |
391d5d2e | 467 | : public __is_member_function_pointer_helper<__remove_cv_t<_Tp>>::type |
53dc5044 PC |
468 | { }; |
469 | ||
470 | /// is_enum | |
471 | template<typename _Tp> | |
472 | struct is_enum | |
473 | : public integral_constant<bool, __is_enum(_Tp)> | |
474 | { }; | |
475 | ||
476 | /// is_union | |
477 | template<typename _Tp> | |
478 | struct is_union | |
479 | : public integral_constant<bool, __is_union(_Tp)> | |
480 | { }; | |
481 | ||
482 | /// is_class | |
483 | template<typename _Tp> | |
484 | struct is_class | |
485 | : public integral_constant<bool, __is_class(_Tp)> | |
486 | { }; | |
487 | ||
488 | /// is_function | |
72459cfd | 489 | template<typename _Tp> |
53dc5044 | 490 | struct is_function |
72459cfd | 491 | : public __bool_constant<!is_const<const _Tp>::value> { }; |
89898034 | 492 | |
72459cfd JW |
493 | template<typename _Tp> |
494 | struct is_function<_Tp&> | |
495 | : public false_type { }; | |
89898034 | 496 | |
72459cfd JW |
497 | template<typename _Tp> |
498 | struct is_function<_Tp&&> | |
499 | : public false_type { }; | |
89898034 | 500 | |
a15f7cb8 ESR |
501 | #define __cpp_lib_is_null_pointer 201309 |
502 | ||
1e673415 | 503 | template<typename> |
aa940ab5 | 504 | struct __is_null_pointer_helper |
1e673415 | 505 | : public false_type { }; |
123c516a PC |
506 | |
507 | template<> | |
aa940ab5 | 508 | struct __is_null_pointer_helper<std::nullptr_t> |
123c516a | 509 | : public true_type { }; |
1e673415 | 510 | |
aa940ab5 PC |
511 | /// is_null_pointer (LWG 2247). |
512 | template<typename _Tp> | |
513 | struct is_null_pointer | |
391d5d2e | 514 | : public __is_null_pointer_helper<__remove_cv_t<_Tp>>::type |
aa940ab5 PC |
515 | { }; |
516 | ||
07fd852f | 517 | /// __is_nullptr_t (deprecated extension). |
1e673415 PC |
518 | template<typename _Tp> |
519 | struct __is_nullptr_t | |
aa940ab5 | 520 | : public is_null_pointer<_Tp> |
07fd852f | 521 | { } _GLIBCXX_DEPRECATED; |
1e673415 | 522 | |
c0ffa2ba | 523 | // Composite type categories. |
123c516a PC |
524 | |
525 | /// is_reference | |
526 | template<typename _Tp> | |
527 | struct is_reference | |
528 | : public __or_<is_lvalue_reference<_Tp>, | |
529 | is_rvalue_reference<_Tp>>::type | |
530 | { }; | |
531 | ||
53dc5044 PC |
532 | /// is_arithmetic |
533 | template<typename _Tp> | |
534 | struct is_arithmetic | |
123c516a | 535 | : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type |
53dc5044 PC |
536 | { }; |
537 | ||
538 | /// is_fundamental | |
539 | template<typename _Tp> | |
540 | struct is_fundamental | |
aa940ab5 PC |
541 | : public __or_<is_arithmetic<_Tp>, is_void<_Tp>, |
542 | is_null_pointer<_Tp>>::type | |
53dc5044 PC |
543 | { }; |
544 | ||
545 | /// is_object | |
546 | template<typename _Tp> | |
547 | struct is_object | |
123c516a PC |
548 | : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>, |
549 | is_void<_Tp>>>::type | |
53dc5044 PC |
550 | { }; |
551 | ||
123c516a | 552 | template<typename> |
53dc5044 PC |
553 | struct is_member_pointer; |
554 | ||
555 | /// is_scalar | |
556 | template<typename _Tp> | |
557 | struct is_scalar | |
123c516a | 558 | : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>, |
aa940ab5 | 559 | is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type |
53dc5044 PC |
560 | { }; |
561 | ||
562 | /// is_compound | |
563 | template<typename _Tp> | |
564 | struct is_compound | |
c01f9216 | 565 | : public __not_<is_fundamental<_Tp>>::type { }; |
53dc5044 | 566 | |
53dc5044 PC |
567 | template<typename _Tp> |
568 | struct __is_member_pointer_helper | |
569 | : public false_type { }; | |
123c516a PC |
570 | |
571 | template<typename _Tp, typename _Cp> | |
572 | struct __is_member_pointer_helper<_Tp _Cp::*> | |
573 | : public true_type { }; | |
53dc5044 | 574 | |
13901e4b | 575 | /// is_member_pointer |
53dc5044 | 576 | template<typename _Tp> |
123c516a | 577 | struct is_member_pointer |
391d5d2e | 578 | : public __is_member_pointer_helper<__remove_cv_t<_Tp>>::type |
53dc5044 PC |
579 | { }; |
580 | ||
47f79054 JW |
581 | template<typename, typename> |
582 | struct is_same; | |
583 | ||
584 | template<typename _Tp, typename... _Types> | |
585 | using __is_one_of = __or_<is_same<_Tp, _Types>...>; | |
586 | ||
587 | // Check if a type is one of the signed integer types. | |
588 | template<typename _Tp> | |
391d5d2e | 589 | using __is_signed_integer = __is_one_of<__remove_cv_t<_Tp>, |
47f79054 JW |
590 | signed char, signed short, signed int, signed long, |
591 | signed long long | |
592 | #if defined(__GLIBCXX_TYPE_INT_N_0) | |
593 | , signed __GLIBCXX_TYPE_INT_N_0 | |
594 | #endif | |
595 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
596 | , signed __GLIBCXX_TYPE_INT_N_1 | |
597 | #endif | |
598 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
599 | , signed __GLIBCXX_TYPE_INT_N_2 | |
600 | #endif | |
601 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
602 | , signed __GLIBCXX_TYPE_INT_N_3 | |
603 | #endif | |
604 | >; | |
605 | ||
606 | // Check if a type is one of the unsigned integer types. | |
607 | template<typename _Tp> | |
391d5d2e | 608 | using __is_unsigned_integer = __is_one_of<__remove_cv_t<_Tp>, |
47f79054 JW |
609 | unsigned char, unsigned short, unsigned int, unsigned long, |
610 | unsigned long long | |
611 | #if defined(__GLIBCXX_TYPE_INT_N_0) | |
612 | , unsigned __GLIBCXX_TYPE_INT_N_0 | |
613 | #endif | |
614 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
615 | , unsigned __GLIBCXX_TYPE_INT_N_1 | |
616 | #endif | |
617 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
618 | , unsigned __GLIBCXX_TYPE_INT_N_2 | |
619 | #endif | |
620 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
621 | , unsigned __GLIBCXX_TYPE_INT_N_3 | |
622 | #endif | |
623 | >; | |
624 | ||
625 | ||
72459cfd JW |
626 | // __void_t (std::void_t for C++11) |
627 | template<typename...> using __void_t = void; | |
628 | ||
89898034 DK |
629 | // Utility to detect referenceable types ([defns.referenceable]). |
630 | ||
72459cfd | 631 | template<typename _Tp, typename = void> |
89898034 | 632 | struct __is_referenceable |
72459cfd | 633 | : public false_type |
89898034 DK |
634 | { }; |
635 | ||
72459cfd JW |
636 | template<typename _Tp> |
637 | struct __is_referenceable<_Tp, __void_t<_Tp&>> | |
89898034 DK |
638 | : public true_type |
639 | { }; | |
640 | ||
c0ffa2ba | 641 | // Type properties. |
123c516a | 642 | |
53dc5044 PC |
643 | /// is_const |
644 | template<typename> | |
645 | struct is_const | |
646 | : public false_type { }; | |
647 | ||
648 | template<typename _Tp> | |
649 | struct is_const<_Tp const> | |
650 | : public true_type { }; | |
33ac58d5 | 651 | |
53dc5044 PC |
652 | /// is_volatile |
653 | template<typename> | |
654 | struct is_volatile | |
655 | : public false_type { }; | |
656 | ||
657 | template<typename _Tp> | |
658 | struct is_volatile<_Tp volatile> | |
659 | : public true_type { }; | |
660 | ||
123c516a PC |
661 | /// is_trivial |
662 | template<typename _Tp> | |
663 | struct is_trivial | |
664 | : public integral_constant<bool, __is_trivial(_Tp)> | |
608a080c AP |
665 | { |
666 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
667 | "template argument must be a complete class or an unbounded array"); | |
668 | }; | |
123c516a | 669 | |
f5e523b7 VV |
670 | // is_trivially_copyable |
671 | template<typename _Tp> | |
672 | struct is_trivially_copyable | |
673 | : public integral_constant<bool, __is_trivially_copyable(_Tp)> | |
608a080c AP |
674 | { |
675 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
676 | "template argument must be a complete class or an unbounded array"); | |
677 | }; | |
123c516a PC |
678 | |
679 | /// is_standard_layout | |
680 | template<typename _Tp> | |
681 | struct is_standard_layout | |
682 | : public integral_constant<bool, __is_standard_layout(_Tp)> | |
608a080c AP |
683 | { |
684 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
685 | "template argument must be a complete class or an unbounded array"); | |
686 | }; | |
123c516a | 687 | |
1a6c5064 | 688 | /// is_pod (deprecated in C++20) |
123c516a PC |
689 | // Could use is_standard_layout && is_trivial instead of the builtin. |
690 | template<typename _Tp> | |
1a6c5064 JTM |
691 | struct |
692 | _GLIBCXX20_DEPRECATED("use is_standard_layout && is_trivial instead") | |
693 | is_pod | |
123c516a | 694 | : public integral_constant<bool, __is_pod(_Tp)> |
608a080c AP |
695 | { |
696 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
697 | "template argument must be a complete class or an unbounded array"); | |
698 | }; | |
123c516a PC |
699 | |
700 | /// is_literal_type | |
701 | template<typename _Tp> | |
702 | struct is_literal_type | |
703 | : public integral_constant<bool, __is_literal_type(_Tp)> | |
608a080c AP |
704 | { |
705 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
706 | "template argument must be a complete class or an unbounded array"); | |
707 | }; | |
123c516a | 708 | |
53dc5044 PC |
709 | /// is_empty |
710 | template<typename _Tp> | |
711 | struct is_empty | |
712 | : public integral_constant<bool, __is_empty(_Tp)> | |
209ee624 | 713 | { }; |
53dc5044 PC |
714 | |
715 | /// is_polymorphic | |
716 | template<typename _Tp> | |
717 | struct is_polymorphic | |
718 | : public integral_constant<bool, __is_polymorphic(_Tp)> | |
209ee624 | 719 | { }; |
53dc5044 | 720 | |
4db7fcb9 ESR |
721 | #if __cplusplus >= 201402L |
722 | #define __cpp_lib_is_final 201402L | |
723 | /// is_final | |
724 | template<typename _Tp> | |
725 | struct is_final | |
726 | : public integral_constant<bool, __is_final(_Tp)> | |
209ee624 | 727 | { }; |
4db7fcb9 ESR |
728 | #endif |
729 | ||
53dc5044 PC |
730 | /// is_abstract |
731 | template<typename _Tp> | |
732 | struct is_abstract | |
733 | : public integral_constant<bool, __is_abstract(_Tp)> | |
209ee624 | 734 | { }; |
53dc5044 | 735 | |
123c516a | 736 | template<typename _Tp, |
6a4b1a00 | 737 | bool = is_arithmetic<_Tp>::value> |
123c516a PC |
738 | struct __is_signed_helper |
739 | : public false_type { }; | |
740 | ||
53dc5044 | 741 | template<typename _Tp> |
6a4b1a00 PC |
742 | struct __is_signed_helper<_Tp, true> |
743 | : public integral_constant<bool, _Tp(-1) < _Tp(0)> | |
53dc5044 PC |
744 | { }; |
745 | ||
123c516a | 746 | /// is_signed |
53dc5044 | 747 | template<typename _Tp> |
123c516a | 748 | struct is_signed |
82b12c4b | 749 | : public __is_signed_helper<_Tp>::type |
123c516a PC |
750 | { }; |
751 | ||
752 | /// is_unsigned | |
753 | template<typename _Tp> | |
754 | struct is_unsigned | |
f7632193 | 755 | : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>> |
123c516a PC |
756 | { }; |
757 | ||
758 | ||
c0ffa2ba | 759 | // Destructible and constructible type properties. |
123c516a | 760 | |
13901e4b JW |
761 | /** |
762 | * @brief Utility to simplify expressions used in unevaluated operands | |
763 | * @ingroup utilities | |
764 | */ | |
ec26ff5a JW |
765 | |
766 | template<typename _Tp, typename _Up = _Tp&&> | |
767 | _Up | |
768 | __declval(int); | |
769 | ||
770 | template<typename _Tp> | |
771 | _Tp | |
772 | __declval(long); | |
773 | ||
53dc5044 | 774 | template<typename _Tp> |
ec26ff5a | 775 | auto declval() noexcept -> decltype(__declval<_Tp>(0)); |
53dc5044 | 776 | |
123c516a PC |
777 | template<typename, unsigned = 0> |
778 | struct extent; | |
779 | ||
780 | template<typename> | |
781 | struct remove_all_extents; | |
782 | ||
783 | template<typename _Tp> | |
784 | struct __is_array_known_bounds | |
785 | : public integral_constant<bool, (extent<_Tp>::value > 0)> | |
53dc5044 PC |
786 | { }; |
787 | ||
123c516a PC |
788 | template<typename _Tp> |
789 | struct __is_array_unknown_bounds | |
f7632193 | 790 | : public __and_<is_array<_Tp>, __not_<extent<_Tp>>> |
53dc5044 | 791 | { }; |
33ac58d5 | 792 | |
62fa805f | 793 | // In N3290 is_destructible does not say anything about function |
2c7a09d7 | 794 | // types and abstract types, see LWG 2049. This implementation |
62fa805f DK |
795 | // describes function types as non-destructible and all complete |
796 | // object types as destructible, iff the explicit destructor | |
2c7a09d7 | 797 | // call expression is wellformed. |
62fa805f | 798 | struct __do_is_destructible_impl |
123c516a | 799 | { |
62fa805f | 800 | template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())> |
123c516a PC |
801 | static true_type __test(int); |
802 | ||
803 | template<typename> | |
804 | static false_type __test(...); | |
805 | }; | |
53dc5044 PC |
806 | |
807 | template<typename _Tp> | |
62fa805f DK |
808 | struct __is_destructible_impl |
809 | : public __do_is_destructible_impl | |
123c516a PC |
810 | { |
811 | typedef decltype(__test<_Tp>(0)) type; | |
812 | }; | |
53dc5044 | 813 | |
62fa805f DK |
814 | template<typename _Tp, |
815 | bool = __or_<is_void<_Tp>, | |
816 | __is_array_unknown_bounds<_Tp>, | |
817 | is_function<_Tp>>::value, | |
818 | bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> | |
819 | struct __is_destructible_safe; | |
820 | ||
821 | template<typename _Tp> | |
822 | struct __is_destructible_safe<_Tp, false, false> | |
823 | : public __is_destructible_impl<typename | |
824 | remove_all_extents<_Tp>::type>::type | |
825 | { }; | |
826 | ||
827 | template<typename _Tp> | |
828 | struct __is_destructible_safe<_Tp, true, false> | |
829 | : public false_type { }; | |
830 | ||
831 | template<typename _Tp> | |
832 | struct __is_destructible_safe<_Tp, false, true> | |
833 | : public true_type { }; | |
834 | ||
835 | /// is_destructible | |
836 | template<typename _Tp> | |
837 | struct is_destructible | |
82b12c4b | 838 | : public __is_destructible_safe<_Tp>::type |
608a080c AP |
839 | { |
840 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
841 | "template argument must be a complete class or an unbounded array"); | |
842 | }; | |
62fa805f DK |
843 | |
844 | // is_nothrow_destructible requires that is_destructible is | |
845 | // satisfied as well. We realize that by mimicing the | |
846 | // implementation of is_destructible but refer to noexcept(expr) | |
847 | // instead of decltype(expr). | |
848 | struct __do_is_nt_destructible_impl | |
123c516a | 849 | { |
62fa805f | 850 | template<typename _Tp> |
c01f9216 JW |
851 | static __bool_constant<noexcept(declval<_Tp&>().~_Tp())> |
852 | __test(int); | |
123c516a PC |
853 | |
854 | template<typename> | |
855 | static false_type __test(...); | |
856 | }; | |
53dc5044 | 857 | |
53dc5044 | 858 | template<typename _Tp> |
62fa805f DK |
859 | struct __is_nt_destructible_impl |
860 | : public __do_is_nt_destructible_impl | |
123c516a PC |
861 | { |
862 | typedef decltype(__test<_Tp>(0)) type; | |
863 | }; | |
864 | ||
865 | template<typename _Tp, | |
866 | bool = __or_<is_void<_Tp>, | |
62fa805f DK |
867 | __is_array_unknown_bounds<_Tp>, |
868 | is_function<_Tp>>::value, | |
869 | bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> | |
870 | struct __is_nt_destructible_safe; | |
53dc5044 PC |
871 | |
872 | template<typename _Tp> | |
62fa805f DK |
873 | struct __is_nt_destructible_safe<_Tp, false, false> |
874 | : public __is_nt_destructible_impl<typename | |
875 | remove_all_extents<_Tp>::type>::type | |
123c516a PC |
876 | { }; |
877 | ||
53dc5044 | 878 | template<typename _Tp> |
62fa805f | 879 | struct __is_nt_destructible_safe<_Tp, true, false> |
123c516a | 880 | : public false_type { }; |
53dc5044 PC |
881 | |
882 | template<typename _Tp> | |
62fa805f | 883 | struct __is_nt_destructible_safe<_Tp, false, true> |
123c516a PC |
884 | : public true_type { }; |
885 | ||
62fa805f | 886 | /// is_nothrow_destructible |
53dc5044 | 887 | template<typename _Tp> |
62fa805f | 888 | struct is_nothrow_destructible |
82b12c4b | 889 | : public __is_nt_destructible_safe<_Tp>::type |
608a080c AP |
890 | { |
891 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
892 | "template argument must be a complete class or an unbounded array"); | |
893 | }; | |
894 | ||
895 | template<typename _Tp, typename... _Args> | |
896 | struct __is_constructible_impl | |
897 | : public __bool_constant<__is_constructible(_Tp, _Args...)> | |
123c516a PC |
898 | { }; |
899 | ||
58487c21 JW |
900 | /// is_constructible |
901 | template<typename _Tp, typename... _Args> | |
902 | struct is_constructible | |
608a080c AP |
903 | : public __is_constructible_impl<_Tp, _Args...> |
904 | { | |
905 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
906 | "template argument must be a complete class or an unbounded array"); | |
907 | }; | |
4a27a739 | 908 | |
123c516a | 909 | /// is_default_constructible |
4a27a739 | 910 | template<typename _Tp> |
123c516a | 911 | struct is_default_constructible |
608a080c AP |
912 | : public __is_constructible_impl<_Tp>::type |
913 | { | |
914 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
915 | "template argument must be a complete class or an unbounded array"); | |
916 | }; | |
c32097d8 | 917 | |
89898034 | 918 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
65cee9bd | 919 | struct __is_copy_constructible_impl; |
123c516a | 920 | |
65cee9bd | 921 | template<typename _Tp> |
89898034 | 922 | struct __is_copy_constructible_impl<_Tp, false> |
65cee9bd PC |
923 | : public false_type { }; |
924 | ||
925 | template<typename _Tp> | |
89898034 | 926 | struct __is_copy_constructible_impl<_Tp, true> |
608a080c | 927 | : public __is_constructible_impl<_Tp, const _Tp&> |
65cee9bd PC |
928 | { }; |
929 | ||
930 | /// is_copy_constructible | |
931 | template<typename _Tp> | |
932 | struct is_copy_constructible | |
933 | : public __is_copy_constructible_impl<_Tp> | |
608a080c AP |
934 | { |
935 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
936 | "template argument must be a complete class or an unbounded array"); | |
937 | }; | |
65cee9bd | 938 | |
89898034 | 939 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
65cee9bd PC |
940 | struct __is_move_constructible_impl; |
941 | ||
942 | template<typename _Tp> | |
89898034 | 943 | struct __is_move_constructible_impl<_Tp, false> |
65cee9bd PC |
944 | : public false_type { }; |
945 | ||
946 | template<typename _Tp> | |
89898034 | 947 | struct __is_move_constructible_impl<_Tp, true> |
608a080c | 948 | : public __is_constructible_impl<_Tp, _Tp&&> |
65cee9bd PC |
949 | { }; |
950 | ||
951 | /// is_move_constructible | |
952 | template<typename _Tp> | |
953 | struct is_move_constructible | |
954 | : public __is_move_constructible_impl<_Tp> | |
608a080c AP |
955 | { |
956 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
957 | "template argument must be a complete class or an unbounded array"); | |
958 | }; | |
65cee9bd PC |
959 | |
960 | template<typename _Tp> | |
961 | struct __is_nt_default_constructible_atom | |
962 | : public integral_constant<bool, noexcept(_Tp())> | |
963 | { }; | |
964 | ||
965 | template<typename _Tp, bool = is_array<_Tp>::value> | |
966 | struct __is_nt_default_constructible_impl; | |
967 | ||
968 | template<typename _Tp> | |
969 | struct __is_nt_default_constructible_impl<_Tp, true> | |
970 | : public __and_<__is_array_known_bounds<_Tp>, | |
971 | __is_nt_default_constructible_atom<typename | |
f7632193 | 972 | remove_all_extents<_Tp>::type>> |
65cee9bd PC |
973 | { }; |
974 | ||
975 | template<typename _Tp> | |
976 | struct __is_nt_default_constructible_impl<_Tp, false> | |
977 | : public __is_nt_default_constructible_atom<_Tp> | |
978 | { }; | |
979 | ||
608a080c AP |
980 | template<typename _Tp> |
981 | using __is_nothrow_default_constructible_impl | |
982 | = __and_<__is_constructible_impl<_Tp>, | |
983 | __is_nt_default_constructible_impl<_Tp>>; | |
984 | ||
65cee9bd PC |
985 | /// is_nothrow_default_constructible |
986 | template<typename _Tp> | |
987 | struct is_nothrow_default_constructible | |
608a080c AP |
988 | : public __is_nothrow_default_constructible_impl<_Tp>::type |
989 | { | |
990 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
991 | "template argument must be a complete class or an unbounded array"); | |
992 | }; | |
e4f32cb0 PC |
993 | |
994 | template<typename _Tp, typename... _Args> | |
65cee9bd PC |
995 | struct __is_nt_constructible_impl |
996 | : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> | |
997 | { }; | |
e4f32cb0 PC |
998 | |
999 | template<typename _Tp, typename _Arg> | |
65cee9bd PC |
1000 | struct __is_nt_constructible_impl<_Tp, _Arg> |
1001 | : public integral_constant<bool, | |
1002 | noexcept(static_cast<_Tp>(declval<_Arg>()))> | |
1003 | { }; | |
1004 | ||
1005 | template<typename _Tp> | |
1006 | struct __is_nt_constructible_impl<_Tp> | |
608a080c | 1007 | : public __is_nothrow_default_constructible_impl<_Tp> |
65cee9bd | 1008 | { }; |
e4f32cb0 | 1009 | |
e4f32cb0 | 1010 | template<typename _Tp, typename... _Args> |
608a080c AP |
1011 | struct __is_nothrow_constructible_impl |
1012 | : public __and_<__is_constructible_impl<_Tp, _Args...>, | |
f7632193 | 1013 | __is_nt_constructible_impl<_Tp, _Args...>> |
65cee9bd PC |
1014 | { }; |
1015 | ||
608a080c AP |
1016 | /// is_nothrow_constructible |
1017 | template<typename _Tp, typename... _Args> | |
1018 | struct is_nothrow_constructible | |
1019 | : public __is_nothrow_constructible_impl<_Tp, _Args...>::type | |
1020 | { | |
1021 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1022 | "template argument must be a complete class or an unbounded array"); | |
1023 | }; | |
1024 | ||
89898034 | 1025 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
65cee9bd PC |
1026 | struct __is_nothrow_copy_constructible_impl; |
1027 | ||
1028 | template<typename _Tp> | |
89898034 | 1029 | struct __is_nothrow_copy_constructible_impl<_Tp, false> |
65cee9bd PC |
1030 | : public false_type { }; |
1031 | ||
1032 | template<typename _Tp> | |
89898034 | 1033 | struct __is_nothrow_copy_constructible_impl<_Tp, true> |
608a080c | 1034 | : public __is_nothrow_constructible_impl<_Tp, const _Tp&> |
65cee9bd PC |
1035 | { }; |
1036 | ||
1037 | /// is_nothrow_copy_constructible | |
1038 | template<typename _Tp> | |
1039 | struct is_nothrow_copy_constructible | |
608a080c AP |
1040 | : public __is_nothrow_copy_constructible_impl<_Tp>::type |
1041 | { | |
1042 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1043 | "template argument must be a complete class or an unbounded array"); | |
1044 | }; | |
65cee9bd | 1045 | |
89898034 | 1046 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
65cee9bd PC |
1047 | struct __is_nothrow_move_constructible_impl; |
1048 | ||
1049 | template<typename _Tp> | |
89898034 | 1050 | struct __is_nothrow_move_constructible_impl<_Tp, false> |
65cee9bd PC |
1051 | : public false_type { }; |
1052 | ||
1053 | template<typename _Tp> | |
89898034 | 1054 | struct __is_nothrow_move_constructible_impl<_Tp, true> |
608a080c | 1055 | : public __is_nothrow_constructible_impl<_Tp, _Tp&&> |
65cee9bd PC |
1056 | { }; |
1057 | ||
1058 | /// is_nothrow_move_constructible | |
1059 | template<typename _Tp> | |
1060 | struct is_nothrow_move_constructible | |
608a080c AP |
1061 | : public __is_nothrow_move_constructible_impl<_Tp>::type |
1062 | { | |
1063 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1064 | "template argument must be a complete class or an unbounded array"); | |
1065 | }; | |
65cee9bd | 1066 | |
f263981a PC |
1067 | /// is_assignable |
1068 | template<typename _Tp, typename _Up> | |
1069 | struct is_assignable | |
608a080c AP |
1070 | : public __bool_constant<__is_assignable(_Tp, _Up)> |
1071 | { | |
1072 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1073 | "template argument must be a complete class or an unbounded array"); | |
1074 | }; | |
f263981a | 1075 | |
89898034 | 1076 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
f263981a PC |
1077 | struct __is_copy_assignable_impl; |
1078 | ||
1079 | template<typename _Tp> | |
89898034 | 1080 | struct __is_copy_assignable_impl<_Tp, false> |
f263981a PC |
1081 | : public false_type { }; |
1082 | ||
1083 | template<typename _Tp> | |
89898034 | 1084 | struct __is_copy_assignable_impl<_Tp, true> |
608a080c | 1085 | : public __bool_constant<__is_assignable(_Tp&, const _Tp&)> |
f263981a PC |
1086 | { }; |
1087 | ||
1088 | /// is_copy_assignable | |
1089 | template<typename _Tp> | |
1090 | struct is_copy_assignable | |
608a080c AP |
1091 | : public __is_copy_assignable_impl<_Tp>::type |
1092 | { | |
1093 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1094 | "template argument must be a complete class or an unbounded array"); | |
1095 | }; | |
f263981a | 1096 | |
89898034 | 1097 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
f263981a PC |
1098 | struct __is_move_assignable_impl; |
1099 | ||
1100 | template<typename _Tp> | |
89898034 | 1101 | struct __is_move_assignable_impl<_Tp, false> |
f263981a PC |
1102 | : public false_type { }; |
1103 | ||
1104 | template<typename _Tp> | |
89898034 | 1105 | struct __is_move_assignable_impl<_Tp, true> |
608a080c | 1106 | : public __bool_constant<__is_assignable(_Tp&, _Tp&&)> |
f263981a PC |
1107 | { }; |
1108 | ||
1109 | /// is_move_assignable | |
1110 | template<typename _Tp> | |
1111 | struct is_move_assignable | |
608a080c AP |
1112 | : public __is_move_assignable_impl<_Tp>::type |
1113 | { | |
1114 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1115 | "template argument must be a complete class or an unbounded array"); | |
1116 | }; | |
f263981a PC |
1117 | |
1118 | template<typename _Tp, typename _Up> | |
1119 | struct __is_nt_assignable_impl | |
1120 | : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())> | |
1121 | { }; | |
1122 | ||
f263981a | 1123 | template<typename _Tp, typename _Up> |
608a080c AP |
1124 | struct __is_nothrow_assignable_impl |
1125 | : public __and_<__bool_constant<__is_assignable(_Tp, _Up)>, | |
f7632193 | 1126 | __is_nt_assignable_impl<_Tp, _Up>> |
f263981a PC |
1127 | { }; |
1128 | ||
608a080c AP |
1129 | /// is_nothrow_assignable |
1130 | template<typename _Tp, typename _Up> | |
1131 | struct is_nothrow_assignable | |
1132 | : public __is_nothrow_assignable_impl<_Tp, _Up> | |
1133 | { | |
1134 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1135 | "template argument must be a complete class or an unbounded array"); | |
1136 | }; | |
1137 | ||
89898034 | 1138 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
f263981a PC |
1139 | struct __is_nt_copy_assignable_impl; |
1140 | ||
1141 | template<typename _Tp> | |
89898034 | 1142 | struct __is_nt_copy_assignable_impl<_Tp, false> |
f263981a PC |
1143 | : public false_type { }; |
1144 | ||
1145 | template<typename _Tp> | |
89898034 | 1146 | struct __is_nt_copy_assignable_impl<_Tp, true> |
608a080c | 1147 | : public __is_nothrow_assignable_impl<_Tp&, const _Tp&> |
f263981a PC |
1148 | { }; |
1149 | ||
1150 | /// is_nothrow_copy_assignable | |
1151 | template<typename _Tp> | |
1152 | struct is_nothrow_copy_assignable | |
1153 | : public __is_nt_copy_assignable_impl<_Tp> | |
608a080c AP |
1154 | { |
1155 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1156 | "template argument must be a complete class or an unbounded array"); | |
1157 | }; | |
f263981a | 1158 | |
89898034 | 1159 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
f263981a PC |
1160 | struct __is_nt_move_assignable_impl; |
1161 | ||
1162 | template<typename _Tp> | |
89898034 | 1163 | struct __is_nt_move_assignable_impl<_Tp, false> |
f263981a PC |
1164 | : public false_type { }; |
1165 | ||
1166 | template<typename _Tp> | |
89898034 | 1167 | struct __is_nt_move_assignable_impl<_Tp, true> |
608a080c | 1168 | : public __is_nothrow_assignable_impl<_Tp&, _Tp&&> |
f263981a PC |
1169 | { }; |
1170 | ||
1171 | /// is_nothrow_move_assignable | |
65cee9bd | 1172 | template<typename _Tp> |
f263981a PC |
1173 | struct is_nothrow_move_assignable |
1174 | : public __is_nt_move_assignable_impl<_Tp> | |
608a080c AP |
1175 | { |
1176 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1177 | "template argument must be a complete class or an unbounded array"); | |
1178 | }; | |
e4f32cb0 | 1179 | |
f5e523b7 VV |
1180 | /// is_trivially_constructible |
1181 | template<typename _Tp, typename... _Args> | |
1182 | struct is_trivially_constructible | |
c01f9216 | 1183 | : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)> |
608a080c AP |
1184 | { |
1185 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1186 | "template argument must be a complete class or an unbounded array"); | |
1187 | }; | |
33ac58d5 | 1188 | |
f5e523b7 VV |
1189 | /// is_trivially_default_constructible |
1190 | template<typename _Tp> | |
1191 | struct is_trivially_default_constructible | |
608a080c AP |
1192 | : public __bool_constant<__is_trivially_constructible(_Tp)> |
1193 | { | |
1194 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1195 | "template argument must be a complete class or an unbounded array"); | |
1196 | }; | |
6a9ecd34 | 1197 | |
f7632193 VV |
1198 | struct __do_is_implicitly_default_constructible_impl |
1199 | { | |
1200 | template <typename _Tp> | |
1201 | static void __helper(const _Tp&); | |
1202 | ||
1203 | template <typename _Tp> | |
1204 | static true_type __test(const _Tp&, | |
1205 | decltype(__helper<const _Tp&>({}))* = 0); | |
1206 | ||
1207 | static false_type __test(...); | |
1208 | }; | |
1209 | ||
1210 | template<typename _Tp> | |
1211 | struct __is_implicitly_default_constructible_impl | |
e9029d55 JW |
1212 | : public __do_is_implicitly_default_constructible_impl |
1213 | { | |
1214 | typedef decltype(__test(declval<_Tp>())) type; | |
1215 | }; | |
f7632193 VV |
1216 | |
1217 | template<typename _Tp> | |
1218 | struct __is_implicitly_default_constructible_safe | |
e9029d55 JW |
1219 | : public __is_implicitly_default_constructible_impl<_Tp>::type |
1220 | { }; | |
f7632193 VV |
1221 | |
1222 | template <typename _Tp> | |
1223 | struct __is_implicitly_default_constructible | |
608a080c | 1224 | : public __and_<__is_constructible_impl<_Tp>, |
e9029d55 JW |
1225 | __is_implicitly_default_constructible_safe<_Tp>> |
1226 | { }; | |
f7632193 | 1227 | |
b42cc3ca VV |
1228 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1229 | struct __is_trivially_copy_constructible_impl; | |
1230 | ||
f5e523b7 | 1231 | template<typename _Tp> |
b42cc3ca VV |
1232 | struct __is_trivially_copy_constructible_impl<_Tp, false> |
1233 | : public false_type { }; | |
1234 | ||
1235 | template<typename _Tp> | |
1236 | struct __is_trivially_copy_constructible_impl<_Tp, true> | |
608a080c | 1237 | : public __and_<__is_copy_constructible_impl<_Tp>, |
f5e523b7 | 1238 | integral_constant<bool, |
f7632193 | 1239 | __is_trivially_constructible(_Tp, const _Tp&)>> |
f5e523b7 | 1240 | { }; |
33ac58d5 | 1241 | |
608a080c | 1242 | /// is_trivially_copy_constructible |
b42cc3ca VV |
1243 | template<typename _Tp> |
1244 | struct is_trivially_copy_constructible | |
1245 | : public __is_trivially_copy_constructible_impl<_Tp> | |
608a080c AP |
1246 | { |
1247 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1248 | "template argument must be a complete class or an unbounded array"); | |
1249 | }; | |
b42cc3ca VV |
1250 | |
1251 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> | |
1252 | struct __is_trivially_move_constructible_impl; | |
1253 | ||
f5e523b7 | 1254 | template<typename _Tp> |
b42cc3ca VV |
1255 | struct __is_trivially_move_constructible_impl<_Tp, false> |
1256 | : public false_type { }; | |
1257 | ||
1258 | template<typename _Tp> | |
1259 | struct __is_trivially_move_constructible_impl<_Tp, true> | |
608a080c | 1260 | : public __and_<__is_move_constructible_impl<_Tp>, |
f5e523b7 | 1261 | integral_constant<bool, |
f7632193 | 1262 | __is_trivially_constructible(_Tp, _Tp&&)>> |
f5e523b7 | 1263 | { }; |
6a9ecd34 | 1264 | |
608a080c | 1265 | /// is_trivially_move_constructible |
b42cc3ca VV |
1266 | template<typename _Tp> |
1267 | struct is_trivially_move_constructible | |
1268 | : public __is_trivially_move_constructible_impl<_Tp> | |
608a080c AP |
1269 | { |
1270 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1271 | "template argument must be a complete class or an unbounded array"); | |
1272 | }; | |
b42cc3ca | 1273 | |
f5e523b7 VV |
1274 | /// is_trivially_assignable |
1275 | template<typename _Tp, typename _Up> | |
1276 | struct is_trivially_assignable | |
b42cc3ca | 1277 | : public __bool_constant<__is_trivially_assignable(_Tp, _Up)> |
608a080c AP |
1278 | { |
1279 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1280 | "template argument must be a complete class or an unbounded array"); | |
1281 | }; | |
b42cc3ca VV |
1282 | |
1283 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> | |
1284 | struct __is_trivially_copy_assignable_impl; | |
1285 | ||
f5e523b7 | 1286 | template<typename _Tp> |
b42cc3ca VV |
1287 | struct __is_trivially_copy_assignable_impl<_Tp, false> |
1288 | : public false_type { }; | |
1289 | ||
1290 | template<typename _Tp> | |
1291 | struct __is_trivially_copy_assignable_impl<_Tp, true> | |
c01f9216 | 1292 | : public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)> |
f5e523b7 | 1293 | { }; |
6a9ecd34 | 1294 | |
608a080c | 1295 | /// is_trivially_copy_assignable |
b42cc3ca VV |
1296 | template<typename _Tp> |
1297 | struct is_trivially_copy_assignable | |
1298 | : public __is_trivially_copy_assignable_impl<_Tp> | |
608a080c AP |
1299 | { |
1300 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1301 | "template argument must be a complete class or an unbounded array"); | |
1302 | }; | |
b42cc3ca VV |
1303 | |
1304 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> | |
1305 | struct __is_trivially_move_assignable_impl; | |
1306 | ||
f5e523b7 | 1307 | template<typename _Tp> |
b42cc3ca VV |
1308 | struct __is_trivially_move_assignable_impl<_Tp, false> |
1309 | : public false_type { }; | |
1310 | ||
1311 | template<typename _Tp> | |
1312 | struct __is_trivially_move_assignable_impl<_Tp, true> | |
c01f9216 | 1313 | : public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)> |
f5e523b7 | 1314 | { }; |
6a9ecd34 | 1315 | |
608a080c | 1316 | /// is_trivially_move_assignable |
b42cc3ca VV |
1317 | template<typename _Tp> |
1318 | struct is_trivially_move_assignable | |
1319 | : public __is_trivially_move_assignable_impl<_Tp> | |
608a080c AP |
1320 | { |
1321 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1322 | "template argument must be a complete class or an unbounded array"); | |
1323 | }; | |
b42cc3ca | 1324 | |
6a9ecd34 PC |
1325 | /// is_trivially_destructible |
1326 | template<typename _Tp> | |
1327 | struct is_trivially_destructible | |
608a080c | 1328 | : public __and_<__is_destructible_safe<_Tp>, |
c01f9216 | 1329 | __bool_constant<__has_trivial_destructor(_Tp)>> |
608a080c AP |
1330 | { |
1331 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1332 | "template argument must be a complete class or an unbounded array"); | |
1333 | }; | |
6a9ecd34 | 1334 | |
e133ace8 | 1335 | |
123c516a PC |
1336 | /// has_virtual_destructor |
1337 | template<typename _Tp> | |
1338 | struct has_virtual_destructor | |
1339 | : public integral_constant<bool, __has_virtual_destructor(_Tp)> | |
608a080c AP |
1340 | { |
1341 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1342 | "template argument must be a complete class or an unbounded array"); | |
1343 | }; | |
123c516a | 1344 | |
33ac58d5 | 1345 | |
123c516a PC |
1346 | // type property queries. |
1347 | ||
1348 | /// alignment_of | |
1349 | template<typename _Tp> | |
1350 | struct alignment_of | |
608a080c AP |
1351 | : public integral_constant<std::size_t, alignof(_Tp)> |
1352 | { | |
1353 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1354 | "template argument must be a complete class or an unbounded array"); | |
1355 | }; | |
33ac58d5 | 1356 | |
123c516a PC |
1357 | /// rank |
1358 | template<typename> | |
1359 | struct rank | |
1360 | : public integral_constant<std::size_t, 0> { }; | |
33ac58d5 | 1361 | |
123c516a PC |
1362 | template<typename _Tp, std::size_t _Size> |
1363 | struct rank<_Tp[_Size]> | |
1364 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | |
1365 | ||
1366 | template<typename _Tp> | |
1367 | struct rank<_Tp[]> | |
1368 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | |
1369 | ||
1370 | /// extent | |
1371 | template<typename, unsigned _Uint> | |
1372 | struct extent | |
1373 | : public integral_constant<std::size_t, 0> { }; | |
33ac58d5 | 1374 | |
123c516a PC |
1375 | template<typename _Tp, unsigned _Uint, std::size_t _Size> |
1376 | struct extent<_Tp[_Size], _Uint> | |
1377 | : public integral_constant<std::size_t, | |
1378 | _Uint == 0 ? _Size : extent<_Tp, | |
1379 | _Uint - 1>::value> | |
1380 | { }; | |
1381 | ||
1382 | template<typename _Tp, unsigned _Uint> | |
1383 | struct extent<_Tp[], _Uint> | |
1384 | : public integral_constant<std::size_t, | |
1385 | _Uint == 0 ? 0 : extent<_Tp, | |
1386 | _Uint - 1>::value> | |
1387 | { }; | |
1388 | ||
1389 | ||
c0ffa2ba | 1390 | // Type relations. |
123c516a PC |
1391 | |
1392 | /// is_same | |
02f6fdff | 1393 | template<typename _Tp, typename _Up> |
123c516a | 1394 | struct is_same |
44af818f JW |
1395 | #ifdef _GLIBCXX_BUILTIN_IS_SAME_AS |
1396 | : public integral_constant<bool, _GLIBCXX_BUILTIN_IS_SAME_AS(_Tp, _Up)> | |
1397 | #else | |
1398 | : public false_type | |
1399 | #endif | |
02f6fdff | 1400 | { }; |
b0302c68 | 1401 | |
44af818f JW |
1402 | #ifndef _GLIBCXX_BUILTIN_IS_SAME_AS |
1403 | template<typename _Tp> | |
1404 | struct is_same<_Tp, _Tp> | |
1405 | : public true_type | |
1406 | { }; | |
1407 | #endif | |
1408 | ||
939759fc | 1409 | /// is_base_of |
e133ace8 PC |
1410 | template<typename _Base, typename _Derived> |
1411 | struct is_base_of | |
1412 | : public integral_constant<bool, __is_base_of(_Base, _Derived)> | |
1413 | { }; | |
1414 | ||
297f34d7 | 1415 | template<typename _From, typename _To, |
123c516a PC |
1416 | bool = __or_<is_void<_From>, is_function<_To>, |
1417 | is_array<_To>>::value> | |
297f34d7 | 1418 | struct __is_convertible_helper |
8df27fcb JW |
1419 | { |
1420 | typedef typename is_void<_To>::type type; | |
8df27fcb | 1421 | }; |
297f34d7 | 1422 | |
cc28d234 JW |
1423 | #pragma GCC diagnostic push |
1424 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | |
e133ace8 | 1425 | template<typename _From, typename _To> |
b0302c68 | 1426 | class __is_convertible_helper<_From, _To, false> |
e133ace8 | 1427 | { |
8df27fcb JW |
1428 | template<typename _To1> |
1429 | static void __test_aux(_To1) noexcept; | |
8e7d962a | 1430 | |
82b12c4b FD |
1431 | template<typename _From1, typename _To1, |
1432 | typename = decltype(__test_aux<_To1>(std::declval<_From1>()))> | |
1433 | static true_type | |
8e7d962a PC |
1434 | __test(int); |
1435 | ||
1436 | template<typename, typename> | |
82b12c4b FD |
1437 | static false_type |
1438 | __test(...); | |
297f34d7 | 1439 | |
e133ace8 | 1440 | public: |
82b12c4b | 1441 | typedef decltype(__test<_From, _To>(0)) type; |
e133ace8 | 1442 | }; |
cc28d234 | 1443 | #pragma GCC diagnostic pop |
82b12c4b | 1444 | |
b0302c68 | 1445 | /// is_convertible |
e133ace8 PC |
1446 | template<typename _From, typename _To> |
1447 | struct is_convertible | |
82b12c4b | 1448 | : public __is_convertible_helper<_From, _To>::type |
e133ace8 PC |
1449 | { }; |
1450 | ||
608a080c | 1451 | template<typename _From, typename _To, |
ed99e818 JW |
1452 | bool = __or_<is_void<_From>, is_function<_To>, |
1453 | is_array<_To>>::value> | |
1454 | struct __is_nt_convertible_helper | |
1455 | : is_void<_To> | |
1456 | { }; | |
1457 | ||
cc28d234 JW |
1458 | #pragma GCC diagnostic push |
1459 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | |
ed99e818 JW |
1460 | template<typename _From, typename _To> |
1461 | class __is_nt_convertible_helper<_From, _To, false> | |
1462 | { | |
1463 | template<typename _To1> | |
1464 | static void __test_aux(_To1) noexcept; | |
1465 | ||
1466 | template<typename _From1, typename _To1> | |
ce9f305e JW |
1467 | static |
1468 | __bool_constant<noexcept(__test_aux<_To1>(std::declval<_From1>()))> | |
ed99e818 JW |
1469 | __test(int); |
1470 | ||
1471 | template<typename, typename> | |
1472 | static false_type | |
1473 | __test(...); | |
1474 | ||
1475 | public: | |
1476 | using type = decltype(__test<_From, _To>(0)); | |
1477 | }; | |
cc28d234 | 1478 | #pragma GCC diagnostic pop |
ed99e818 | 1479 | |
a7922ddf JTM |
1480 | // helper trait for unique_ptr<T[]>, shared_ptr<T[]>, and span<T, N> |
1481 | template<typename _ToElementType, typename _FromElementType> | |
1482 | using __is_array_convertible | |
1483 | = is_convertible<_FromElementType(*)[], _ToElementType(*)[]>; | |
1484 | ||
ce9f305e JW |
1485 | // is_nothrow_convertible for C++11 |
1486 | template<typename _From, typename _To> | |
1487 | struct __is_nothrow_convertible | |
1488 | : public __is_nt_convertible_helper<_From, _To>::type | |
1489 | { }; | |
1490 | ||
1491 | #if __cplusplus > 201703L | |
8df27fcb JW |
1492 | /// is_nothrow_convertible |
1493 | template<typename _From, typename _To> | |
1494 | struct is_nothrow_convertible | |
ed99e818 | 1495 | : public __is_nt_convertible_helper<_From, _To>::type |
8df27fcb JW |
1496 | { }; |
1497 | ||
1498 | /// is_nothrow_convertible_v | |
1499 | template<typename _From, typename _To> | |
1500 | inline constexpr bool is_nothrow_convertible_v | |
1501 | = is_nothrow_convertible<_From, _To>::value; | |
1502 | #endif // C++2a | |
fd735b6a | 1503 | |
c0ffa2ba | 1504 | // Const-volatile modifications. |
7b50cdef | 1505 | |
123c516a | 1506 | /// remove_const |
7b50cdef | 1507 | template<typename _Tp> |
123c516a PC |
1508 | struct remove_const |
1509 | { typedef _Tp type; }; | |
7b50cdef | 1510 | |
123c516a PC |
1511 | template<typename _Tp> |
1512 | struct remove_const<_Tp const> | |
1513 | { typedef _Tp type; }; | |
33ac58d5 | 1514 | |
123c516a PC |
1515 | /// remove_volatile |
1516 | template<typename _Tp> | |
1517 | struct remove_volatile | |
1518 | { typedef _Tp type; }; | |
7b50cdef | 1519 | |
123c516a PC |
1520 | template<typename _Tp> |
1521 | struct remove_volatile<_Tp volatile> | |
1522 | { typedef _Tp type; }; | |
33ac58d5 | 1523 | |
123c516a PC |
1524 | /// remove_cv |
1525 | template<typename _Tp> | |
1526 | struct remove_cv | |
391d5d2e JW |
1527 | { using type = _Tp; }; |
1528 | ||
1529 | template<typename _Tp> | |
1530 | struct remove_cv<const _Tp> | |
1531 | { using type = _Tp; }; | |
1532 | ||
1533 | template<typename _Tp> | |
1534 | struct remove_cv<volatile _Tp> | |
1535 | { using type = _Tp; }; | |
1536 | ||
1537 | template<typename _Tp> | |
1538 | struct remove_cv<const volatile _Tp> | |
1539 | { using type = _Tp; }; | |
33ac58d5 | 1540 | |
123c516a PC |
1541 | /// add_const |
1542 | template<typename _Tp> | |
1543 | struct add_const | |
1544 | { typedef _Tp const type; }; | |
33ac58d5 | 1545 | |
123c516a PC |
1546 | /// add_volatile |
1547 | template<typename _Tp> | |
1548 | struct add_volatile | |
1549 | { typedef _Tp volatile type; }; | |
33ac58d5 | 1550 | |
123c516a PC |
1551 | /// add_cv |
1552 | template<typename _Tp> | |
1553 | struct add_cv | |
1554 | { | |
1555 | typedef typename | |
1556 | add_const<typename add_volatile<_Tp>::type>::type type; | |
1557 | }; | |
7b50cdef | 1558 | |
4457e88c | 1559 | #if __cplusplus > 201103L |
a15f7cb8 ESR |
1560 | |
1561 | #define __cpp_lib_transformation_trait_aliases 201304 | |
1562 | ||
4457e88c JW |
1563 | /// Alias template for remove_const |
1564 | template<typename _Tp> | |
1565 | using remove_const_t = typename remove_const<_Tp>::type; | |
1566 | ||
1567 | /// Alias template for remove_volatile | |
1568 | template<typename _Tp> | |
1569 | using remove_volatile_t = typename remove_volatile<_Tp>::type; | |
1570 | ||
1571 | /// Alias template for remove_cv | |
1572 | template<typename _Tp> | |
1573 | using remove_cv_t = typename remove_cv<_Tp>::type; | |
1574 | ||
1575 | /// Alias template for add_const | |
1576 | template<typename _Tp> | |
1577 | using add_const_t = typename add_const<_Tp>::type; | |
1578 | ||
1579 | /// Alias template for add_volatile | |
1580 | template<typename _Tp> | |
1581 | using add_volatile_t = typename add_volatile<_Tp>::type; | |
1582 | ||
1583 | /// Alias template for add_cv | |
1584 | template<typename _Tp> | |
1585 | using add_cv_t = typename add_cv<_Tp>::type; | |
1586 | #endif | |
7b50cdef | 1587 | |
123c516a | 1588 | // Reference transformations. |
7b50cdef | 1589 | |
123c516a PC |
1590 | /// remove_reference |
1591 | template<typename _Tp> | |
1592 | struct remove_reference | |
1593 | { typedef _Tp type; }; | |
7b50cdef | 1594 | |
123c516a PC |
1595 | template<typename _Tp> |
1596 | struct remove_reference<_Tp&> | |
1597 | { typedef _Tp type; }; | |
7b50cdef | 1598 | |
123c516a PC |
1599 | template<typename _Tp> |
1600 | struct remove_reference<_Tp&&> | |
1601 | { typedef _Tp type; }; | |
1602 | ||
89898034 | 1603 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
123c516a PC |
1604 | struct __add_lvalue_reference_helper |
1605 | { typedef _Tp type; }; | |
7b50cdef | 1606 | |
5e108459 | 1607 | template<typename _Tp> |
89898034 | 1608 | struct __add_lvalue_reference_helper<_Tp, true> |
123c516a | 1609 | { typedef _Tp& type; }; |
5e108459 | 1610 | |
123c516a | 1611 | /// add_lvalue_reference |
5e108459 | 1612 | template<typename _Tp> |
123c516a PC |
1613 | struct add_lvalue_reference |
1614 | : public __add_lvalue_reference_helper<_Tp> | |
1615 | { }; | |
1616 | ||
89898034 | 1617 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
123c516a PC |
1618 | struct __add_rvalue_reference_helper |
1619 | { typedef _Tp type; }; | |
5e108459 PC |
1620 | |
1621 | template<typename _Tp> | |
123c516a PC |
1622 | struct __add_rvalue_reference_helper<_Tp, true> |
1623 | { typedef _Tp&& type; }; | |
5e108459 | 1624 | |
123c516a | 1625 | /// add_rvalue_reference |
5e108459 | 1626 | template<typename _Tp> |
123c516a PC |
1627 | struct add_rvalue_reference |
1628 | : public __add_rvalue_reference_helper<_Tp> | |
1629 | { }; | |
5e108459 | 1630 | |
4457e88c JW |
1631 | #if __cplusplus > 201103L |
1632 | /// Alias template for remove_reference | |
1633 | template<typename _Tp> | |
1634 | using remove_reference_t = typename remove_reference<_Tp>::type; | |
1635 | ||
1636 | /// Alias template for add_lvalue_reference | |
1637 | template<typename _Tp> | |
1638 | using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; | |
1639 | ||
1640 | /// Alias template for add_rvalue_reference | |
1641 | template<typename _Tp> | |
1642 | using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; | |
1643 | #endif | |
7b50cdef | 1644 | |
c0ffa2ba | 1645 | // Sign modifications. |
123c516a | 1646 | |
7b50cdef BK |
1647 | // Utility for constructing identically cv-qualified types. |
1648 | template<typename _Unqualified, bool _IsConst, bool _IsVol> | |
1649 | struct __cv_selector; | |
1650 | ||
1651 | template<typename _Unqualified> | |
1652 | struct __cv_selector<_Unqualified, false, false> | |
1653 | { typedef _Unqualified __type; }; | |
1654 | ||
1655 | template<typename _Unqualified> | |
1656 | struct __cv_selector<_Unqualified, false, true> | |
1657 | { typedef volatile _Unqualified __type; }; | |
1658 | ||
1659 | template<typename _Unqualified> | |
1660 | struct __cv_selector<_Unqualified, true, false> | |
1661 | { typedef const _Unqualified __type; }; | |
1662 | ||
1663 | template<typename _Unqualified> | |
1664 | struct __cv_selector<_Unqualified, true, true> | |
1665 | { typedef const volatile _Unqualified __type; }; | |
1666 | ||
1667 | template<typename _Qualified, typename _Unqualified, | |
1668 | bool _IsConst = is_const<_Qualified>::value, | |
1669 | bool _IsVol = is_volatile<_Qualified>::value> | |
b0302c68 | 1670 | class __match_cv_qualifiers |
7b50cdef | 1671 | { |
7b50cdef BK |
1672 | typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; |
1673 | ||
1674 | public: | |
33ac58d5 | 1675 | typedef typename __match::__type __type; |
7b50cdef BK |
1676 | }; |
1677 | ||
7b50cdef BK |
1678 | // Utility for finding the unsigned versions of signed integral types. |
1679 | template<typename _Tp> | |
e133ace8 PC |
1680 | struct __make_unsigned |
1681 | { typedef _Tp __type; }; | |
7b50cdef BK |
1682 | |
1683 | template<> | |
1684 | struct __make_unsigned<char> | |
1685 | { typedef unsigned char __type; }; | |
1686 | ||
1687 | template<> | |
1688 | struct __make_unsigned<signed char> | |
1689 | { typedef unsigned char __type; }; | |
1690 | ||
7b50cdef BK |
1691 | template<> |
1692 | struct __make_unsigned<short> | |
1693 | { typedef unsigned short __type; }; | |
1694 | ||
1695 | template<> | |
1696 | struct __make_unsigned<int> | |
1697 | { typedef unsigned int __type; }; | |
1698 | ||
1699 | template<> | |
1700 | struct __make_unsigned<long> | |
1701 | { typedef unsigned long __type; }; | |
1702 | ||
1703 | template<> | |
1704 | struct __make_unsigned<long long> | |
1705 | { typedef unsigned long long __type; }; | |
1706 | ||
78a7c317 DD |
1707 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
1708 | template<> | |
1709 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0> | |
1710 | { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; }; | |
1711 | #endif | |
1712 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
1713 | template<> | |
1714 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1> | |
1715 | { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; }; | |
1716 | #endif | |
1717 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
6d585f01 | 1718 | template<> |
78a7c317 DD |
1719 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2> |
1720 | { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; }; | |
1721 | #endif | |
1722 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
1723 | template<> | |
1724 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3> | |
1725 | { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; }; | |
6d585f01 PC |
1726 | #endif |
1727 | ||
7b50cdef | 1728 | // Select between integral and enum: not possible to be both. |
33ac58d5 | 1729 | template<typename _Tp, |
7b50cdef | 1730 | bool _IsInt = is_integral<_Tp>::value, |
7b50cdef | 1731 | bool _IsEnum = is_enum<_Tp>::value> |
b0302c68 PC |
1732 | class __make_unsigned_selector; |
1733 | ||
7b50cdef | 1734 | template<typename _Tp> |
b0302c68 | 1735 | class __make_unsigned_selector<_Tp, true, false> |
7b50cdef | 1736 | { |
22f1f4c7 | 1737 | using __unsigned_type |
391d5d2e | 1738 | = typename __make_unsigned<__remove_cv_t<_Tp>>::__type; |
7b50cdef BK |
1739 | |
1740 | public: | |
22f1f4c7 JW |
1741 | using __type |
1742 | = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; | |
7b50cdef BK |
1743 | }; |
1744 | ||
22f1f4c7 JW |
1745 | class __make_unsigned_selector_base |
1746 | { | |
1747 | protected: | |
1748 | template<typename...> struct _List { }; | |
1749 | ||
1750 | template<typename _Tp, typename... _Up> | |
1751 | struct _List<_Tp, _Up...> : _List<_Up...> | |
1752 | { static constexpr size_t __size = sizeof(_Tp); }; | |
1753 | ||
1754 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | |
1755 | struct __select; | |
1756 | ||
1757 | template<size_t _Sz, typename _Uint, typename... _UInts> | |
1758 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | |
1759 | { using __type = _Uint; }; | |
1760 | ||
1761 | template<size_t _Sz, typename _Uint, typename... _UInts> | |
1762 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | |
1763 | : __select<_Sz, _List<_UInts...>> | |
1764 | { }; | |
1765 | }; | |
1766 | ||
1767 | // Choose unsigned integer type with the smallest rank and same size as _Tp | |
7b50cdef | 1768 | template<typename _Tp> |
b0302c68 | 1769 | class __make_unsigned_selector<_Tp, false, true> |
22f1f4c7 | 1770 | : __make_unsigned_selector_base |
7b50cdef | 1771 | { |
a0230468 | 1772 | // With -fshort-enums, an enum may be as small as a char. |
22f1f4c7 JW |
1773 | using _UInts = _List<unsigned char, unsigned short, unsigned int, |
1774 | unsigned long, unsigned long long>; | |
1775 | ||
1776 | using __unsigned_type = typename __select<sizeof(_Tp), _UInts>::__type; | |
73d81d3a | 1777 | |
7b50cdef | 1778 | public: |
22f1f4c7 JW |
1779 | using __type |
1780 | = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; | |
1781 | }; | |
1782 | ||
c124af93 TH |
1783 | // wchar_t, char8_t, char16_t and char32_t are integral types but are |
1784 | // neither signed integer types nor unsigned integer types, so must be | |
22f1f4c7 JW |
1785 | // transformed to the unsigned integer type with the smallest rank. |
1786 | // Use the partial specialization for enumeration types to do that. | |
1787 | #if defined(_GLIBCXX_USE_WCHAR_T) | |
1788 | template<> | |
1789 | struct __make_unsigned<wchar_t> | |
1790 | { | |
1791 | using __type | |
1792 | = typename __make_unsigned_selector<wchar_t, false, true>::__type; | |
1793 | }; | |
1794 | #endif | |
1795 | ||
c124af93 TH |
1796 | #ifdef _GLIBCXX_USE_CHAR8_T |
1797 | template<> | |
1798 | struct __make_unsigned<char8_t> | |
1799 | { | |
1800 | using __type | |
1801 | = typename __make_unsigned_selector<char8_t, false, true>::__type; | |
1802 | }; | |
1803 | #endif | |
1804 | ||
22f1f4c7 JW |
1805 | template<> |
1806 | struct __make_unsigned<char16_t> | |
1807 | { | |
1808 | using __type | |
1809 | = typename __make_unsigned_selector<char16_t, false, true>::__type; | |
1810 | }; | |
1811 | ||
1812 | template<> | |
1813 | struct __make_unsigned<char32_t> | |
1814 | { | |
1815 | using __type | |
1816 | = typename __make_unsigned_selector<char32_t, false, true>::__type; | |
7b50cdef BK |
1817 | }; |
1818 | ||
7b50cdef BK |
1819 | // Given an integral/enum type, return the corresponding unsigned |
1820 | // integer type. | |
5b9daa7e BK |
1821 | // Primary template. |
1822 | /// make_unsigned | |
7b50cdef | 1823 | template<typename _Tp> |
33ac58d5 | 1824 | struct make_unsigned |
7b50cdef BK |
1825 | { typedef typename __make_unsigned_selector<_Tp>::__type type; }; |
1826 | ||
1827 | // Integral, but don't define. | |
1828 | template<> | |
1829 | struct make_unsigned<bool>; | |
1830 | ||
1831 | ||
1832 | // Utility for finding the signed versions of unsigned integral types. | |
1833 | template<typename _Tp> | |
e133ace8 PC |
1834 | struct __make_signed |
1835 | { typedef _Tp __type; }; | |
7b50cdef BK |
1836 | |
1837 | template<> | |
1838 | struct __make_signed<char> | |
1839 | { typedef signed char __type; }; | |
1840 | ||
1841 | template<> | |
1842 | struct __make_signed<unsigned char> | |
1843 | { typedef signed char __type; }; | |
1844 | ||
7b50cdef BK |
1845 | template<> |
1846 | struct __make_signed<unsigned short> | |
1847 | { typedef signed short __type; }; | |
1848 | ||
1849 | template<> | |
1850 | struct __make_signed<unsigned int> | |
1851 | { typedef signed int __type; }; | |
1852 | ||
1853 | template<> | |
1854 | struct __make_signed<unsigned long> | |
1855 | { typedef signed long __type; }; | |
1856 | ||
1857 | template<> | |
1858 | struct __make_signed<unsigned long long> | |
1859 | { typedef signed long long __type; }; | |
1860 | ||
78a7c317 DD |
1861 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
1862 | template<> | |
1863 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0> | |
1864 | { typedef __GLIBCXX_TYPE_INT_N_0 __type; }; | |
1865 | #endif | |
1866 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
1867 | template<> | |
1868 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1> | |
1869 | { typedef __GLIBCXX_TYPE_INT_N_1 __type; }; | |
1870 | #endif | |
1871 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
1872 | template<> | |
1873 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2> | |
1874 | { typedef __GLIBCXX_TYPE_INT_N_2 __type; }; | |
1875 | #endif | |
1876 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
6d585f01 | 1877 | template<> |
78a7c317 DD |
1878 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3> |
1879 | { typedef __GLIBCXX_TYPE_INT_N_3 __type; }; | |
6d585f01 PC |
1880 | #endif |
1881 | ||
fb8ffd10 | 1882 | // Select between integral and enum: not possible to be both. |
33ac58d5 | 1883 | template<typename _Tp, |
7b50cdef | 1884 | bool _IsInt = is_integral<_Tp>::value, |
7b50cdef | 1885 | bool _IsEnum = is_enum<_Tp>::value> |
b0302c68 PC |
1886 | class __make_signed_selector; |
1887 | ||
7b50cdef | 1888 | template<typename _Tp> |
b0302c68 | 1889 | class __make_signed_selector<_Tp, true, false> |
7b50cdef | 1890 | { |
22f1f4c7 | 1891 | using __signed_type |
391d5d2e | 1892 | = typename __make_signed<__remove_cv_t<_Tp>>::__type; |
7b50cdef BK |
1893 | |
1894 | public: | |
22f1f4c7 JW |
1895 | using __type |
1896 | = typename __match_cv_qualifiers<_Tp, __signed_type>::__type; | |
7b50cdef BK |
1897 | }; |
1898 | ||
22f1f4c7 | 1899 | // Choose signed integer type with the smallest rank and same size as _Tp |
7b50cdef | 1900 | template<typename _Tp> |
b0302c68 | 1901 | class __make_signed_selector<_Tp, false, true> |
7b50cdef | 1902 | { |
73d81d3a | 1903 | typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type; |
7b50cdef BK |
1904 | |
1905 | public: | |
73d81d3a | 1906 | typedef typename __make_signed_selector<__unsigned_type>::__type __type; |
7b50cdef BK |
1907 | }; |
1908 | ||
22f1f4c7 | 1909 | // wchar_t, char16_t and char32_t are integral types but are neither |
d4b695e4 | 1910 | // signed integer types nor unsigned integer types, so must be |
22f1f4c7 JW |
1911 | // transformed to the signed integer type with the smallest rank. |
1912 | // Use the partial specialization for enumeration types to do that. | |
1913 | #if defined(_GLIBCXX_USE_WCHAR_T) | |
1914 | template<> | |
1915 | struct __make_signed<wchar_t> | |
1916 | { | |
1917 | using __type | |
1918 | = typename __make_signed_selector<wchar_t, false, true>::__type; | |
1919 | }; | |
1920 | #endif | |
1921 | ||
c124af93 TH |
1922 | #if defined(_GLIBCXX_USE_CHAR8_T) |
1923 | template<> | |
1924 | struct __make_signed<char8_t> | |
1925 | { | |
1926 | using __type | |
1927 | = typename __make_signed_selector<char8_t, false, true>::__type; | |
1928 | }; | |
1929 | #endif | |
1930 | ||
22f1f4c7 JW |
1931 | template<> |
1932 | struct __make_signed<char16_t> | |
1933 | { | |
1934 | using __type | |
1935 | = typename __make_signed_selector<char16_t, false, true>::__type; | |
1936 | }; | |
1937 | ||
1938 | template<> | |
1939 | struct __make_signed<char32_t> | |
1940 | { | |
1941 | using __type | |
1942 | = typename __make_signed_selector<char32_t, false, true>::__type; | |
1943 | }; | |
1944 | ||
7b50cdef BK |
1945 | // Given an integral/enum type, return the corresponding signed |
1946 | // integer type. | |
5b9daa7e BK |
1947 | // Primary template. |
1948 | /// make_signed | |
7b50cdef | 1949 | template<typename _Tp> |
33ac58d5 | 1950 | struct make_signed |
7b50cdef BK |
1951 | { typedef typename __make_signed_selector<_Tp>::__type type; }; |
1952 | ||
1953 | // Integral, but don't define. | |
1954 | template<> | |
1955 | struct make_signed<bool>; | |
cfa9a96b | 1956 | |
4457e88c JW |
1957 | #if __cplusplus > 201103L |
1958 | /// Alias template for make_signed | |
1959 | template<typename _Tp> | |
1960 | using make_signed_t = typename make_signed<_Tp>::type; | |
1961 | ||
1962 | /// Alias template for make_unsigned | |
1963 | template<typename _Tp> | |
1964 | using make_unsigned_t = typename make_unsigned<_Tp>::type; | |
1965 | #endif | |
123c516a | 1966 | |
c0ffa2ba | 1967 | // Array modifications. |
123c516a PC |
1968 | |
1969 | /// remove_extent | |
1970 | template<typename _Tp> | |
1971 | struct remove_extent | |
1972 | { typedef _Tp type; }; | |
1973 | ||
1974 | template<typename _Tp, std::size_t _Size> | |
1975 | struct remove_extent<_Tp[_Size]> | |
1976 | { typedef _Tp type; }; | |
1977 | ||
1978 | template<typename _Tp> | |
1979 | struct remove_extent<_Tp[]> | |
1980 | { typedef _Tp type; }; | |
1981 | ||
1982 | /// remove_all_extents | |
1983 | template<typename _Tp> | |
1984 | struct remove_all_extents | |
1985 | { typedef _Tp type; }; | |
1986 | ||
1987 | template<typename _Tp, std::size_t _Size> | |
1988 | struct remove_all_extents<_Tp[_Size]> | |
1989 | { typedef typename remove_all_extents<_Tp>::type type; }; | |
1990 | ||
1991 | template<typename _Tp> | |
1992 | struct remove_all_extents<_Tp[]> | |
1993 | { typedef typename remove_all_extents<_Tp>::type type; }; | |
1994 | ||
4457e88c JW |
1995 | #if __cplusplus > 201103L |
1996 | /// Alias template for remove_extent | |
1997 | template<typename _Tp> | |
1998 | using remove_extent_t = typename remove_extent<_Tp>::type; | |
1999 | ||
2000 | /// Alias template for remove_all_extents | |
2001 | template<typename _Tp> | |
2002 | using remove_all_extents_t = typename remove_all_extents<_Tp>::type; | |
2003 | #endif | |
123c516a | 2004 | |
c0ffa2ba | 2005 | // Pointer modifications. |
123c516a PC |
2006 | |
2007 | template<typename _Tp, typename> | |
2008 | struct __remove_pointer_helper | |
2009 | { typedef _Tp type; }; | |
2010 | ||
2011 | template<typename _Tp, typename _Up> | |
2012 | struct __remove_pointer_helper<_Tp, _Up*> | |
2013 | { typedef _Up type; }; | |
2014 | ||
2015 | /// remove_pointer | |
2016 | template<typename _Tp> | |
2017 | struct remove_pointer | |
391d5d2e | 2018 | : public __remove_pointer_helper<_Tp, __remove_cv_t<_Tp>> |
123c516a PC |
2019 | { }; |
2020 | ||
2021 | /// add_pointer | |
89898034 DK |
2022 | template<typename _Tp, bool = __or_<__is_referenceable<_Tp>, |
2023 | is_void<_Tp>>::value> | |
2024 | struct __add_pointer_helper | |
2025 | { typedef _Tp type; }; | |
2026 | ||
123c516a | 2027 | template<typename _Tp> |
89898034 | 2028 | struct __add_pointer_helper<_Tp, true> |
123c516a PC |
2029 | { typedef typename remove_reference<_Tp>::type* type; }; |
2030 | ||
89898034 | 2031 | template<typename _Tp> |
33ac58d5 | 2032 | struct add_pointer |
89898034 DK |
2033 | : public __add_pointer_helper<_Tp> |
2034 | { }; | |
2035 | ||
4457e88c JW |
2036 | #if __cplusplus > 201103L |
2037 | /// Alias template for remove_pointer | |
2038 | template<typename _Tp> | |
2039 | using remove_pointer_t = typename remove_pointer<_Tp>::type; | |
2040 | ||
2041 | /// Alias template for add_pointer | |
2042 | template<typename _Tp> | |
2043 | using add_pointer_t = typename add_pointer<_Tp>::type; | |
2044 | #endif | |
123c516a PC |
2045 | |
2046 | template<std::size_t _Len> | |
2047 | struct __aligned_storage_msa | |
33ac58d5 | 2048 | { |
123c516a PC |
2049 | union __type |
2050 | { | |
2051 | unsigned char __data[_Len]; | |
33ac58d5 | 2052 | struct __attribute__((__aligned__)) { } __align; |
123c516a PC |
2053 | }; |
2054 | }; | |
2055 | ||
2056 | /** | |
2057 | * @brief Alignment type. | |
2058 | * | |
2059 | * The value of _Align is a default-alignment which shall be the | |
2060 | * most stringent alignment requirement for any C++ object type | |
2061 | * whose size is no greater than _Len (3.9). The member typedef | |
2062 | * type shall be a POD type suitable for use as uninitialized | |
2063 | * storage for any object whose size is at most _Len and whose | |
2064 | * alignment is a divisor of _Align. | |
2065 | */ | |
2066 | template<std::size_t _Len, std::size_t _Align = | |
2067 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | |
2068 | struct aligned_storage | |
33ac58d5 | 2069 | { |
123c516a PC |
2070 | union type |
2071 | { | |
2072 | unsigned char __data[_Len]; | |
33ac58d5 | 2073 | struct __attribute__((__aligned__((_Align)))) { } __align; |
123c516a PC |
2074 | }; |
2075 | }; | |
2076 | ||
d3718027 RS |
2077 | template <typename... _Types> |
2078 | struct __strictest_alignment | |
2079 | { | |
2080 | static const size_t _S_alignment = 0; | |
2081 | static const size_t _S_size = 0; | |
2082 | }; | |
2083 | ||
2084 | template <typename _Tp, typename... _Types> | |
2085 | struct __strictest_alignment<_Tp, _Types...> | |
2086 | { | |
2087 | static const size_t _S_alignment = | |
2088 | alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment | |
2089 | ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment; | |
2090 | static const size_t _S_size = | |
2091 | sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size | |
2092 | ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size; | |
2093 | }; | |
2094 | ||
2095 | /** | |
2096 | * @brief Provide aligned storage for types. | |
2097 | * | |
2098 | * [meta.trans.other] | |
2099 | * | |
2100 | * Provides aligned storage for any of the provided types of at | |
2101 | * least size _Len. | |
2102 | * | |
2103 | * @see aligned_storage | |
2104 | */ | |
2105 | template <size_t _Len, typename... _Types> | |
2106 | struct aligned_union | |
2107 | { | |
2108 | private: | |
2109 | static_assert(sizeof...(_Types) != 0, "At least one type is required"); | |
2110 | ||
2111 | using __strictest = __strictest_alignment<_Types...>; | |
2112 | static const size_t _S_len = _Len > __strictest::_S_size | |
2113 | ? _Len : __strictest::_S_size; | |
2114 | public: | |
2115 | /// The value of the strictest alignment of _Types. | |
2116 | static const size_t alignment_value = __strictest::_S_alignment; | |
2117 | /// The storage. | |
2118 | typedef typename aligned_storage<_S_len, alignment_value>::type type; | |
2119 | }; | |
2120 | ||
2121 | template <size_t _Len, typename... _Types> | |
2122 | const size_t aligned_union<_Len, _Types...>::alignment_value; | |
123c516a PC |
2123 | |
2124 | // Decay trait for arrays and functions, used for perfect forwarding | |
2125 | // in make_pair, make_tuple, etc. | |
33ac58d5 | 2126 | template<typename _Up, |
123c516a | 2127 | bool _IsArray = is_array<_Up>::value, |
33ac58d5 | 2128 | bool _IsFunction = is_function<_Up>::value> |
123c516a PC |
2129 | struct __decay_selector; |
2130 | ||
2131 | // NB: DR 705. | |
33ac58d5 | 2132 | template<typename _Up> |
123c516a | 2133 | struct __decay_selector<_Up, false, false> |
391d5d2e | 2134 | { typedef __remove_cv_t<_Up> __type; }; |
123c516a | 2135 | |
33ac58d5 | 2136 | template<typename _Up> |
123c516a PC |
2137 | struct __decay_selector<_Up, true, false> |
2138 | { typedef typename remove_extent<_Up>::type* __type; }; | |
2139 | ||
33ac58d5 | 2140 | template<typename _Up> |
123c516a PC |
2141 | struct __decay_selector<_Up, false, true> |
2142 | { typedef typename add_pointer<_Up>::type __type; }; | |
2143 | ||
2144 | /// decay | |
33ac58d5 JW |
2145 | template<typename _Tp> |
2146 | class decay | |
2147 | { | |
123c516a PC |
2148 | typedef typename remove_reference<_Tp>::type __remove_type; |
2149 | ||
2150 | public: | |
2151 | typedef typename __decay_selector<__remove_type>::__type type; | |
2152 | }; | |
2153 | ||
391d5d2e JW |
2154 | // __decay_t (std::decay_t for C++11). |
2155 | template<typename _Tp> | |
2156 | using __decay_t = typename decay<_Tp>::type; | |
2157 | ||
123c516a PC |
2158 | template<typename _Tp> |
2159 | class reference_wrapper; | |
2160 | ||
2161 | // Helper which adds a reference to a type when given a reference_wrapper | |
2162 | template<typename _Tp> | |
2163 | struct __strip_reference_wrapper | |
2164 | { | |
2165 | typedef _Tp __type; | |
2166 | }; | |
2167 | ||
2168 | template<typename _Tp> | |
2169 | struct __strip_reference_wrapper<reference_wrapper<_Tp> > | |
2170 | { | |
2171 | typedef _Tp& __type; | |
2172 | }; | |
2173 | ||
123c516a | 2174 | template<typename _Tp> |
391d5d2e | 2175 | using __decay_and_strip = __strip_reference_wrapper<__decay_t<_Tp>>; |
123c516a PC |
2176 | |
2177 | ||
123c516a | 2178 | // Primary template. |
13901e4b | 2179 | /// Define a member typedef @c type only if a boolean constant is true. |
123c516a | 2180 | template<bool, typename _Tp = void> |
33ac58d5 | 2181 | struct enable_if |
123c516a PC |
2182 | { }; |
2183 | ||
2184 | // Partial specialization for true. | |
2185 | template<typename _Tp> | |
2186 | struct enable_if<true, _Tp> | |
2187 | { typedef _Tp type; }; | |
2188 | ||
391d5d2e JW |
2189 | // __enable_if_t (std::enable_if_t for C++11) |
2190 | template<bool _Cond, typename _Tp = void> | |
2191 | using __enable_if_t = typename enable_if<_Cond, _Tp>::type; | |
2192 | ||
23df8534 | 2193 | template<typename... _Cond> |
391d5d2e | 2194 | using _Require = __enable_if_t<__and_<_Cond...>::value>; |
123c516a | 2195 | |
123c516a | 2196 | // Primary template. |
13901e4b | 2197 | /// Define a member typedef @c type to one of two argument types. |
123c516a PC |
2198 | template<bool _Cond, typename _Iftrue, typename _Iffalse> |
2199 | struct conditional | |
2200 | { typedef _Iftrue type; }; | |
2201 | ||
2202 | // Partial specialization for false. | |
2203 | template<typename _Iftrue, typename _Iffalse> | |
2204 | struct conditional<false, _Iftrue, _Iffalse> | |
2205 | { typedef _Iffalse type; }; | |
2206 | ||
0f8b14ee JW |
2207 | // __remove_cvref_t (std::remove_cvref_t for C++11). |
2208 | template<typename _Tp> | |
2209 | using __remove_cvref_t | |
2210 | = typename remove_cv<typename remove_reference<_Tp>::type>::type; | |
2211 | ||
5b9daa7e | 2212 | /// common_type |
cfa9a96b CF |
2213 | template<typename... _Tp> |
2214 | struct common_type; | |
2215 | ||
c0ffa2ba | 2216 | // Sfinae-friendly common_type implementation: |
b3618b71 DK |
2217 | |
2218 | struct __do_common_type_impl | |
2219 | { | |
2220 | template<typename _Tp, typename _Up> | |
f61a12b3 JW |
2221 | using __cond_t |
2222 | = decltype(true ? std::declval<_Tp>() : std::declval<_Up>()); | |
2223 | ||
0f8b14ee JW |
2224 | // if decay_t<decltype(false ? declval<D1>() : declval<D2>())> |
2225 | // denotes a valid type, let C denote that type. | |
f61a12b3 | 2226 | template<typename _Tp, typename _Up> |
0f8b14ee | 2227 | static __success_type<__decay_t<__cond_t<_Tp, _Up>>> |
f61a12b3 | 2228 | _S_test(int); |
b3618b71 | 2229 | |
0f8b14ee JW |
2230 | #if __cplusplus > 201703L |
2231 | // Otherwise, if COND-RES(CREF(D1), CREF(D2)) denotes a type, | |
2232 | // let C denote the type decay_t<COND-RES(CREF(D1), CREF(D2))>. | |
2233 | template<typename _Tp, typename _Up> | |
2234 | static __success_type<__remove_cvref_t<__cond_t<const _Tp&, const _Up&>>> | |
2235 | _S_test_2(int); | |
2236 | #endif | |
2237 | ||
b3618b71 | 2238 | template<typename, typename> |
f61a12b3 | 2239 | static __failure_type |
0f8b14ee JW |
2240 | _S_test_2(...); |
2241 | ||
2242 | template<typename _Tp, typename _Up> | |
2243 | static decltype(_S_test_2<_Tp, _Up>(0)) | |
f61a12b3 | 2244 | _S_test(...); |
b3618b71 DK |
2245 | }; |
2246 | ||
f61a12b3 JW |
2247 | // If sizeof...(T) is zero, there shall be no member type. |
2248 | template<> | |
2249 | struct common_type<> | |
2250 | { }; | |
b3618b71 | 2251 | |
f61a12b3 JW |
2252 | // If sizeof...(T) is one, the same type, if any, as common_type_t<T0, T0>. |
2253 | template<typename _Tp0> | |
2254 | struct common_type<_Tp0> | |
2255 | : public common_type<_Tp0, _Tp0> | |
2256 | { }; | |
b3618b71 | 2257 | |
f61a12b3 JW |
2258 | // If sizeof...(T) is two, ... |
2259 | template<typename _Tp1, typename _Tp2, | |
391d5d2e | 2260 | typename _Dp1 = __decay_t<_Tp1>, typename _Dp2 = __decay_t<_Tp2>> |
f61a12b3 | 2261 | struct __common_type_impl |
b3618b71 | 2262 | { |
f61a12b3 JW |
2263 | // If is_same_v<T1, D1> is false or is_same_v<T2, D2> is false, |
2264 | // let C denote the same type, if any, as common_type_t<D1, D2>. | |
2265 | using type = common_type<_Dp1, _Dp2>; | |
b3618b71 DK |
2266 | }; |
2267 | ||
f61a12b3 JW |
2268 | template<typename _Tp1, typename _Tp2> |
2269 | struct __common_type_impl<_Tp1, _Tp2, _Tp1, _Tp2> | |
2270 | : private __do_common_type_impl | |
b3618b71 | 2271 | { |
f61a12b3 JW |
2272 | // Otherwise, if decay_t<decltype(false ? declval<D1>() : declval<D2>())> |
2273 | // denotes a valid type, let C denote that type. | |
2274 | using type = decltype(_S_test<_Tp1, _Tp2>(0)); | |
b3618b71 DK |
2275 | }; |
2276 | ||
f61a12b3 JW |
2277 | // If sizeof...(T) is two, ... |
2278 | template<typename _Tp1, typename _Tp2> | |
2279 | struct common_type<_Tp1, _Tp2> | |
2280 | : public __common_type_impl<_Tp1, _Tp2>::type | |
2281 | { }; | |
b3618b71 | 2282 | |
f61a12b3 JW |
2283 | template<typename...> |
2284 | struct __common_type_pack | |
373c726e JW |
2285 | { }; |
2286 | ||
f61a12b3 JW |
2287 | template<typename, typename, typename = void> |
2288 | struct __common_type_fold; | |
2289 | ||
2290 | // If sizeof...(T) is greater than two, ... | |
2291 | template<typename _Tp1, typename _Tp2, typename... _Rp> | |
2292 | struct common_type<_Tp1, _Tp2, _Rp...> | |
2293 | : public __common_type_fold<common_type<_Tp1, _Tp2>, | |
2294 | __common_type_pack<_Rp...>> | |
373c726e | 2295 | { }; |
cfa9a96b | 2296 | |
f61a12b3 JW |
2297 | // Let C denote the same type, if any, as common_type_t<T1, T2>. |
2298 | // If there is such a type C, type shall denote the same type, if any, | |
2299 | // as common_type_t<C, R...>. | |
2300 | template<typename _CTp, typename... _Rp> | |
2301 | struct __common_type_fold<_CTp, __common_type_pack<_Rp...>, | |
2302 | __void_t<typename _CTp::type>> | |
2303 | : public common_type<typename _CTp::type, _Rp...> | |
b3618b71 | 2304 | { }; |
cfa9a96b | 2305 | |
f61a12b3 JW |
2306 | // Otherwise, there shall be no member type. |
2307 | template<typename _CTp, typename _Rp> | |
2308 | struct __common_type_fold<_CTp, _Rp, void> | |
b3618b71 | 2309 | { }; |
7274deff | 2310 | |
3c26b759 JW |
2311 | template<typename _Tp, bool = is_enum<_Tp>::value> |
2312 | struct __underlying_type_impl | |
2313 | { | |
2314 | using type = __underlying_type(_Tp); | |
2315 | }; | |
2316 | ||
2317 | template<typename _Tp> | |
2318 | struct __underlying_type_impl<_Tp, false> | |
2319 | { }; | |
2320 | ||
13901e4b | 2321 | /// The underlying type of an enum. |
a47407f6 PC |
2322 | template<typename _Tp> |
2323 | struct underlying_type | |
3c26b759 JW |
2324 | : public __underlying_type_impl<_Tp> |
2325 | { }; | |
123c516a | 2326 | |
7274deff PC |
2327 | template<typename _Tp> |
2328 | struct __declval_protector | |
2329 | { | |
2330 | static const bool __stop = false; | |
7274deff PC |
2331 | }; |
2332 | ||
2333 | template<typename _Tp> | |
ec26ff5a | 2334 | auto declval() noexcept -> decltype(__declval<_Tp>(0)) |
7274deff PC |
2335 | { |
2336 | static_assert(__declval_protector<_Tp>::__stop, | |
2337 | "declval() must not be used!"); | |
ec26ff5a | 2338 | return __declval<_Tp>(0); |
7274deff | 2339 | } |
1041daba | 2340 | |
be7f7822 JW |
2341 | /// result_of |
2342 | template<typename _Signature> | |
2343 | class result_of; | |
2344 | ||
c0ffa2ba | 2345 | // Sfinae-friendly result_of implementation: |
83ddb39f | 2346 | |
a15f7cb8 ESR |
2347 | #define __cpp_lib_result_of_sfinae 201210 |
2348 | ||
93e95400 JW |
2349 | struct __invoke_memfun_ref { }; |
2350 | struct __invoke_memfun_deref { }; | |
2351 | struct __invoke_memobj_ref { }; | |
2352 | struct __invoke_memobj_deref { }; | |
2353 | struct __invoke_other { }; | |
2354 | ||
2355 | // Associate a tag type with a specialization of __success_type. | |
2356 | template<typename _Tp, typename _Tag> | |
2357 | struct __result_of_success : __success_type<_Tp> | |
2358 | { using __invoke_type = _Tag; }; | |
2359 | ||
83ddb39f DK |
2360 | // [func.require] paragraph 1 bullet 1: |
2361 | struct __result_of_memfun_ref_impl | |
2362 | { | |
2363 | template<typename _Fp, typename _Tp1, typename... _Args> | |
93e95400 | 2364 | static __result_of_success<decltype( |
83ddb39f | 2365 | (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...) |
93e95400 | 2366 | ), __invoke_memfun_ref> _S_test(int); |
83ddb39f DK |
2367 | |
2368 | template<typename...> | |
2369 | static __failure_type _S_test(...); | |
2370 | }; | |
2371 | ||
2372 | template<typename _MemPtr, typename _Arg, typename... _Args> | |
2373 | struct __result_of_memfun_ref | |
2374 | : private __result_of_memfun_ref_impl | |
2375 | { | |
2376 | typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; | |
2377 | }; | |
2378 | ||
2379 | // [func.require] paragraph 1 bullet 2: | |
2380 | struct __result_of_memfun_deref_impl | |
2381 | { | |
2382 | template<typename _Fp, typename _Tp1, typename... _Args> | |
93e95400 | 2383 | static __result_of_success<decltype( |
83ddb39f | 2384 | ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...) |
93e95400 | 2385 | ), __invoke_memfun_deref> _S_test(int); |
83ddb39f DK |
2386 | |
2387 | template<typename...> | |
2388 | static __failure_type _S_test(...); | |
2389 | }; | |
2390 | ||
2391 | template<typename _MemPtr, typename _Arg, typename... _Args> | |
2392 | struct __result_of_memfun_deref | |
2393 | : private __result_of_memfun_deref_impl | |
2394 | { | |
2395 | typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; | |
2396 | }; | |
2397 | ||
2398 | // [func.require] paragraph 1 bullet 3: | |
2399 | struct __result_of_memobj_ref_impl | |
2400 | { | |
2401 | template<typename _Fp, typename _Tp1> | |
93e95400 | 2402 | static __result_of_success<decltype( |
83ddb39f | 2403 | std::declval<_Tp1>().*std::declval<_Fp>() |
93e95400 | 2404 | ), __invoke_memobj_ref> _S_test(int); |
83ddb39f DK |
2405 | |
2406 | template<typename, typename> | |
2407 | static __failure_type _S_test(...); | |
2408 | }; | |
2409 | ||
2410 | template<typename _MemPtr, typename _Arg> | |
2411 | struct __result_of_memobj_ref | |
2412 | : private __result_of_memobj_ref_impl | |
2413 | { | |
2414 | typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; | |
2415 | }; | |
2416 | ||
2417 | // [func.require] paragraph 1 bullet 4: | |
2418 | struct __result_of_memobj_deref_impl | |
2419 | { | |
2420 | template<typename _Fp, typename _Tp1> | |
93e95400 | 2421 | static __result_of_success<decltype( |
83ddb39f | 2422 | (*std::declval<_Tp1>()).*std::declval<_Fp>() |
93e95400 | 2423 | ), __invoke_memobj_deref> _S_test(int); |
83ddb39f DK |
2424 | |
2425 | template<typename, typename> | |
2426 | static __failure_type _S_test(...); | |
2427 | }; | |
2428 | ||
be7f7822 | 2429 | template<typename _MemPtr, typename _Arg> |
83ddb39f DK |
2430 | struct __result_of_memobj_deref |
2431 | : private __result_of_memobj_deref_impl | |
2432 | { | |
2433 | typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; | |
2434 | }; | |
2435 | ||
2436 | template<typename _MemPtr, typename _Arg> | |
2437 | struct __result_of_memobj; | |
be7f7822 JW |
2438 | |
2439 | template<typename _Res, typename _Class, typename _Arg> | |
83ddb39f | 2440 | struct __result_of_memobj<_Res _Class::*, _Arg> |
be7f7822 | 2441 | { |
6791489e | 2442 | typedef __remove_cvref_t<_Arg> _Argval; |
83ddb39f DK |
2443 | typedef _Res _Class::* _MemPtr; |
2444 | typedef typename conditional<__or_<is_same<_Argval, _Class>, | |
2445 | is_base_of<_Class, _Argval>>::value, | |
2446 | __result_of_memobj_ref<_MemPtr, _Arg>, | |
2447 | __result_of_memobj_deref<_MemPtr, _Arg> | |
2448 | >::type::type type; | |
be7f7822 JW |
2449 | }; |
2450 | ||
83ddb39f DK |
2451 | template<typename _MemPtr, typename _Arg, typename... _Args> |
2452 | struct __result_of_memfun; | |
be7f7822 JW |
2453 | |
2454 | template<typename _Res, typename _Class, typename _Arg, typename... _Args> | |
83ddb39f | 2455 | struct __result_of_memfun<_Res _Class::*, _Arg, _Args...> |
be7f7822 | 2456 | { |
81c7cf71 | 2457 | typedef typename remove_reference<_Arg>::type _Argval; |
83ddb39f | 2458 | typedef _Res _Class::* _MemPtr; |
81c7cf71 | 2459 | typedef typename conditional<is_base_of<_Class, _Argval>::value, |
83ddb39f DK |
2460 | __result_of_memfun_ref<_MemPtr, _Arg, _Args...>, |
2461 | __result_of_memfun_deref<_MemPtr, _Arg, _Args...> | |
2462 | >::type::type type; | |
be7f7822 JW |
2463 | }; |
2464 | ||
93e95400 JW |
2465 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
2466 | // 2219. INVOKE-ing a pointer to member with a reference_wrapper | |
2467 | // as the object expression | |
93e95400 | 2468 | |
7dcc645c | 2469 | // Used by result_of, invoke etc. to unwrap a reference_wrapper. |
81c7cf71 | 2470 | template<typename _Tp, typename _Up = __remove_cvref_t<_Tp>> |
7dcc645c JW |
2471 | struct __inv_unwrap |
2472 | { | |
2473 | using type = _Tp; | |
2474 | }; | |
f3d7dd52 | 2475 | |
7dcc645c JW |
2476 | template<typename _Tp, typename _Up> |
2477 | struct __inv_unwrap<_Tp, reference_wrapper<_Up>> | |
2478 | { | |
2479 | using type = _Up&; | |
2480 | }; | |
93e95400 | 2481 | |
be7f7822 | 2482 | template<bool, bool, typename _Functor, typename... _ArgTypes> |
83ddb39f | 2483 | struct __result_of_impl |
be7f7822 | 2484 | { |
83ddb39f | 2485 | typedef __failure_type type; |
be7f7822 JW |
2486 | }; |
2487 | ||
2488 | template<typename _MemPtr, typename _Arg> | |
83ddb39f | 2489 | struct __result_of_impl<true, false, _MemPtr, _Arg> |
391d5d2e | 2490 | : public __result_of_memobj<__decay_t<_MemPtr>, |
7dcc645c | 2491 | typename __inv_unwrap<_Arg>::type> |
c4db9a77 | 2492 | { }; |
be7f7822 | 2493 | |
83ddb39f DK |
2494 | template<typename _MemPtr, typename _Arg, typename... _Args> |
2495 | struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...> | |
391d5d2e | 2496 | : public __result_of_memfun<__decay_t<_MemPtr>, |
7dcc645c | 2497 | typename __inv_unwrap<_Arg>::type, _Args...> |
c4db9a77 | 2498 | { }; |
be7f7822 | 2499 | |
83ddb39f DK |
2500 | // [func.require] paragraph 1 bullet 5: |
2501 | struct __result_of_other_impl | |
2502 | { | |
2503 | template<typename _Fn, typename... _Args> | |
93e95400 | 2504 | static __result_of_success<decltype( |
83ddb39f | 2505 | std::declval<_Fn>()(std::declval<_Args>()...) |
93e95400 | 2506 | ), __invoke_other> _S_test(int); |
83ddb39f DK |
2507 | |
2508 | template<typename...> | |
2509 | static __failure_type _S_test(...); | |
2510 | }; | |
2511 | ||
be7f7822 | 2512 | template<typename _Functor, typename... _ArgTypes> |
83ddb39f DK |
2513 | struct __result_of_impl<false, false, _Functor, _ArgTypes...> |
2514 | : private __result_of_other_impl | |
be7f7822 | 2515 | { |
83ddb39f | 2516 | typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type; |
be7f7822 JW |
2517 | }; |
2518 | ||
7dcc645c | 2519 | // __invoke_result (std::invoke_result for C++11) |
83ddb39f | 2520 | template<typename _Functor, typename... _ArgTypes> |
7dcc645c | 2521 | struct __invoke_result |
83ddb39f DK |
2522 | : public __result_of_impl< |
2523 | is_member_object_pointer< | |
2524 | typename remove_reference<_Functor>::type | |
2525 | >::value, | |
2526 | is_member_function_pointer< | |
2527 | typename remove_reference<_Functor>::type | |
2528 | >::value, | |
7dcc645c | 2529 | _Functor, _ArgTypes... |
83ddb39f DK |
2530 | >::type |
2531 | { }; | |
c0ffa2ba | 2532 | |
7dcc645c JW |
2533 | template<typename _Functor, typename... _ArgTypes> |
2534 | struct result_of<_Functor(_ArgTypes...)> | |
2535 | : public __invoke_result<_Functor, _ArgTypes...> | |
2536 | { }; | |
2537 | ||
e112d53a | 2538 | #if __cplusplus >= 201402L |
4457e88c JW |
2539 | /// Alias template for aligned_storage |
2540 | template<size_t _Len, size_t _Align = | |
2541 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | |
2542 | using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; | |
2543 | ||
d3718027 RS |
2544 | template <size_t _Len, typename... _Types> |
2545 | using aligned_union_t = typename aligned_union<_Len, _Types...>::type; | |
2546 | ||
4457e88c JW |
2547 | /// Alias template for decay |
2548 | template<typename _Tp> | |
2549 | using decay_t = typename decay<_Tp>::type; | |
2550 | ||
2551 | /// Alias template for enable_if | |
2552 | template<bool _Cond, typename _Tp = void> | |
2553 | using enable_if_t = typename enable_if<_Cond, _Tp>::type; | |
2554 | ||
2555 | /// Alias template for conditional | |
2556 | template<bool _Cond, typename _Iftrue, typename _Iffalse> | |
2557 | using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type; | |
2558 | ||
2559 | /// Alias template for common_type | |
2560 | template<typename... _Tp> | |
2561 | using common_type_t = typename common_type<_Tp...>::type; | |
2562 | ||
2563 | /// Alias template for underlying_type | |
2564 | template<typename _Tp> | |
2565 | using underlying_type_t = typename underlying_type<_Tp>::type; | |
2566 | ||
2567 | /// Alias template for result_of | |
2568 | template<typename _Tp> | |
2569 | using result_of_t = typename result_of<_Tp>::type; | |
e112d53a JW |
2570 | #endif // C++14 |
2571 | ||
e112d53a | 2572 | #if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++11 |
bd1eb5e0 JW |
2573 | #define __cpp_lib_void_t 201411 |
2574 | /// A metafunction that always yields void, used for detecting valid types. | |
2575 | template<typename...> using void_t = void; | |
2576 | #endif | |
2577 | ||
6af6bef4 JW |
2578 | /// Implementation of the detection idiom (negative case). |
2579 | template<typename _Default, typename _AlwaysVoid, | |
2580 | template<typename...> class _Op, typename... _Args> | |
2581 | struct __detector | |
2582 | { | |
2583 | using value_t = false_type; | |
2584 | using type = _Default; | |
2585 | }; | |
2586 | ||
2587 | /// Implementation of the detection idiom (positive case). | |
2588 | template<typename _Default, template<typename...> class _Op, | |
2589 | typename... _Args> | |
2590 | struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...> | |
2591 | { | |
2592 | using value_t = true_type; | |
2593 | using type = _Op<_Args...>; | |
2594 | }; | |
2595 | ||
2596 | // Detect whether _Op<_Args...> is a valid type, use _Default if not. | |
2597 | template<typename _Default, template<typename...> class _Op, | |
2598 | typename... _Args> | |
2599 | using __detected_or = __detector<_Default, void, _Op, _Args...>; | |
2600 | ||
2601 | // _Op<_Args...> if that is a valid type, otherwise _Default. | |
2602 | template<typename _Default, template<typename...> class _Op, | |
2603 | typename... _Args> | |
2604 | using __detected_or_t | |
2605 | = typename __detected_or<_Default, _Op, _Args...>::type; | |
2606 | ||
c0ffa2ba | 2607 | /// @} group metaprogramming |
847e9cf8 | 2608 | |
033b71ce PC |
2609 | /** |
2610 | * Use SFINAE to determine if the type _Tp has a publicly-accessible | |
2611 | * member type _NTYPE. | |
2612 | */ | |
82b12c4b | 2613 | #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \ |
847e9cf8 | 2614 | template<typename _Tp, typename = __void_t<>> \ |
82b12c4b | 2615 | struct __has_##_NTYPE \ |
847e9cf8 JW |
2616 | : false_type \ |
2617 | { }; \ | |
2618 | template<typename _Tp> \ | |
2619 | struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \ | |
2620 | : true_type \ | |
033b71ce PC |
2621 | { }; |
2622 | ||
26b5ace7 DK |
2623 | template <typename _Tp> |
2624 | struct __is_swappable; | |
ddb63209 | 2625 | |
26b5ace7 DK |
2626 | template <typename _Tp> |
2627 | struct __is_nothrow_swappable; | |
ddb63209 | 2628 | |
a2863bde VV |
2629 | template<typename... _Elements> |
2630 | class tuple; | |
2631 | ||
2632 | template<typename> | |
2633 | struct __is_tuple_like_impl : false_type | |
2634 | { }; | |
2635 | ||
2636 | template<typename... _Tps> | |
2637 | struct __is_tuple_like_impl<tuple<_Tps...>> : true_type | |
2638 | { }; | |
2639 | ||
2640 | // Internal type trait that allows us to sfinae-protect tuple_cat. | |
2641 | template<typename _Tp> | |
2642 | struct __is_tuple_like | |
6791489e | 2643 | : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type |
a2863bde VV |
2644 | { }; |
2645 | ||
ddb63209 | 2646 | template<typename _Tp> |
7a91c710 | 2647 | _GLIBCXX20_CONSTEXPR |
ddb63209 | 2648 | inline |
391d5d2e JW |
2649 | _Require<__not_<__is_tuple_like<_Tp>>, |
2650 | is_move_constructible<_Tp>, | |
2651 | is_move_assignable<_Tp>> | |
ddb63209 VV |
2652 | swap(_Tp&, _Tp&) |
2653 | noexcept(__and_<is_nothrow_move_constructible<_Tp>, | |
2654 | is_nothrow_move_assignable<_Tp>>::value); | |
2655 | ||
2656 | template<typename _Tp, size_t _Nm> | |
7a91c710 | 2657 | _GLIBCXX20_CONSTEXPR |
ddb63209 | 2658 | inline |
391d5d2e | 2659 | __enable_if_t<__is_swappable<_Tp>::value> |
ddb63209 | 2660 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) |
26b5ace7 | 2661 | noexcept(__is_nothrow_swappable<_Tp>::value); |
ddb63209 | 2662 | |
26b5ace7 | 2663 | namespace __swappable_details { |
ddb63209 VV |
2664 | using std::swap; |
2665 | ||
26b5ace7 DK |
2666 | struct __do_is_swappable_impl |
2667 | { | |
2668 | template<typename _Tp, typename | |
2669 | = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))> | |
2670 | static true_type __test(int); | |
2671 | ||
2672 | template<typename> | |
2673 | static false_type __test(...); | |
2674 | }; | |
2675 | ||
2676 | struct __do_is_nothrow_swappable_impl | |
2677 | { | |
2678 | template<typename _Tp> | |
2679 | static __bool_constant< | |
2680 | noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())) | |
2681 | > __test(int); | |
2682 | ||
2683 | template<typename> | |
2684 | static false_type __test(...); | |
2685 | }; | |
2686 | ||
6b9539e2 | 2687 | } // namespace __swappable_details |
ddb63209 | 2688 | |
26b5ace7 DK |
2689 | template<typename _Tp> |
2690 | struct __is_swappable_impl | |
2691 | : public __swappable_details::__do_is_swappable_impl | |
2692 | { | |
2693 | typedef decltype(__test<_Tp>(0)) type; | |
2694 | }; | |
2695 | ||
2696 | template<typename _Tp> | |
ddb63209 | 2697 | struct __is_nothrow_swappable_impl |
26b5ace7 DK |
2698 | : public __swappable_details::__do_is_nothrow_swappable_impl |
2699 | { | |
2700 | typedef decltype(__test<_Tp>(0)) type; | |
2701 | }; | |
ddb63209 | 2702 | |
26b5ace7 DK |
2703 | template<typename _Tp> |
2704 | struct __is_swappable | |
2705 | : public __is_swappable_impl<_Tp>::type | |
ddb63209 VV |
2706 | { }; |
2707 | ||
26b5ace7 | 2708 | template<typename _Tp> |
ddb63209 | 2709 | struct __is_nothrow_swappable |
26b5ace7 | 2710 | : public __is_nothrow_swappable_impl<_Tp>::type |
ddb63209 VV |
2711 | { }; |
2712 | ||
6b9539e2 DK |
2713 | #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 |
2714 | #define __cpp_lib_is_swappable 201603 | |
2715 | /// Metafunctions used for detecting swappable types: p0185r1 | |
2716 | ||
2717 | /// is_swappable | |
2718 | template<typename _Tp> | |
2719 | struct is_swappable | |
2720 | : public __is_swappable_impl<_Tp>::type | |
608a080c AP |
2721 | { |
2722 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
2723 | "template argument must be a complete class or an unbounded array"); | |
2724 | }; | |
6b9539e2 DK |
2725 | |
2726 | /// is_nothrow_swappable | |
2727 | template<typename _Tp> | |
2728 | struct is_nothrow_swappable | |
2729 | : public __is_nothrow_swappable_impl<_Tp>::type | |
608a080c AP |
2730 | { |
2731 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
2732 | "template argument must be a complete class or an unbounded array"); | |
2733 | }; | |
6b9539e2 DK |
2734 | |
2735 | #if __cplusplus >= 201402L | |
2736 | /// is_swappable_v | |
2737 | template<typename _Tp> | |
288695f7 DK |
2738 | _GLIBCXX17_INLINE constexpr bool is_swappable_v = |
2739 | is_swappable<_Tp>::value; | |
6b9539e2 DK |
2740 | |
2741 | /// is_nothrow_swappable_v | |
2742 | template<typename _Tp> | |
288695f7 DK |
2743 | _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v = |
2744 | is_nothrow_swappable<_Tp>::value; | |
6b9539e2 DK |
2745 | #endif // __cplusplus >= 201402L |
2746 | ||
2747 | namespace __swappable_with_details { | |
2748 | using std::swap; | |
2749 | ||
2750 | struct __do_is_swappable_with_impl | |
2751 | { | |
2752 | template<typename _Tp, typename _Up, typename | |
2753 | = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())), | |
2754 | typename | |
2755 | = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> | |
2756 | static true_type __test(int); | |
2757 | ||
2758 | template<typename, typename> | |
2759 | static false_type __test(...); | |
2760 | }; | |
2761 | ||
2762 | struct __do_is_nothrow_swappable_with_impl | |
2763 | { | |
2764 | template<typename _Tp, typename _Up> | |
2765 | static __bool_constant< | |
2766 | noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) | |
2767 | && | |
2768 | noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())) | |
2769 | > __test(int); | |
2770 | ||
2771 | template<typename, typename> | |
2772 | static false_type __test(...); | |
2773 | }; | |
2774 | ||
2775 | } // namespace __swappable_with_details | |
2776 | ||
2777 | template<typename _Tp, typename _Up> | |
2778 | struct __is_swappable_with_impl | |
2779 | : public __swappable_with_details::__do_is_swappable_with_impl | |
2780 | { | |
2781 | typedef decltype(__test<_Tp, _Up>(0)) type; | |
2782 | }; | |
2783 | ||
2784 | // Optimization for the homogenous lvalue case, not required: | |
2785 | template<typename _Tp> | |
2786 | struct __is_swappable_with_impl<_Tp&, _Tp&> | |
2787 | : public __swappable_details::__do_is_swappable_impl | |
2788 | { | |
2789 | typedef decltype(__test<_Tp&>(0)) type; | |
2790 | }; | |
2791 | ||
2792 | template<typename _Tp, typename _Up> | |
2793 | struct __is_nothrow_swappable_with_impl | |
2794 | : public __swappable_with_details::__do_is_nothrow_swappable_with_impl | |
2795 | { | |
2796 | typedef decltype(__test<_Tp, _Up>(0)) type; | |
2797 | }; | |
2798 | ||
2799 | // Optimization for the homogenous lvalue case, not required: | |
2800 | template<typename _Tp> | |
2801 | struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&> | |
2802 | : public __swappable_details::__do_is_nothrow_swappable_impl | |
2803 | { | |
2804 | typedef decltype(__test<_Tp&>(0)) type; | |
2805 | }; | |
2806 | ||
2807 | /// is_swappable_with | |
2808 | template<typename _Tp, typename _Up> | |
2809 | struct is_swappable_with | |
2810 | : public __is_swappable_with_impl<_Tp, _Up>::type | |
2811 | { }; | |
2812 | ||
2813 | /// is_nothrow_swappable_with | |
2814 | template<typename _Tp, typename _Up> | |
2815 | struct is_nothrow_swappable_with | |
2816 | : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type | |
2817 | { }; | |
2818 | ||
2819 | #if __cplusplus >= 201402L | |
2820 | /// is_swappable_with_v | |
2821 | template<typename _Tp, typename _Up> | |
288695f7 DK |
2822 | _GLIBCXX17_INLINE constexpr bool is_swappable_with_v = |
2823 | is_swappable_with<_Tp, _Up>::value; | |
6b9539e2 DK |
2824 | |
2825 | /// is_nothrow_swappable_with_v | |
2826 | template<typename _Tp, typename _Up> | |
288695f7 | 2827 | _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v = |
6b9539e2 DK |
2828 | is_nothrow_swappable_with<_Tp, _Up>::value; |
2829 | #endif // __cplusplus >= 201402L | |
137422c8 | 2830 | |
42183d03 JW |
2831 | #endif// c++1z or gnu++11 |
2832 | ||
7dcc645c | 2833 | // __is_invocable (std::is_invocable for C++11) |
42183d03 | 2834 | |
d91f618d JW |
2835 | // The primary template is used for invalid INVOKE expressions. |
2836 | template<typename _Result, typename _Ret, | |
2837 | bool = is_void<_Ret>::value, typename = void> | |
7dcc645c | 2838 | struct __is_invocable_impl : false_type { }; |
42183d03 | 2839 | |
d91f618d | 2840 | // Used for valid INVOKE and INVOKE<void> expressions. |
42183d03 | 2841 | template<typename _Result, typename _Ret> |
d91f618d JW |
2842 | struct __is_invocable_impl<_Result, _Ret, |
2843 | /* is_void<_Ret> = */ true, | |
2844 | __void_t<typename _Result::type>> | |
2845 | : true_type | |
42183d03 JW |
2846 | { }; |
2847 | ||
d91f618d JW |
2848 | #pragma GCC diagnostic push |
2849 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | |
2850 | // Used for INVOKE<R> expressions to check the implicit conversion to R. | |
2851 | template<typename _Result, typename _Ret> | |
2852 | struct __is_invocable_impl<_Result, _Ret, | |
2853 | /* is_void<_Ret> = */ false, | |
2854 | __void_t<typename _Result::type>> | |
2855 | { | |
2856 | private: | |
2857 | // The type of the INVOKE expression. | |
2858 | // Unlike declval, this doesn't add_rvalue_reference. | |
2859 | static typename _Result::type _S_get(); | |
2860 | ||
2861 | template<typename _Tp> | |
2862 | static void _S_conv(_Tp); | |
2863 | ||
2864 | // This overload is viable if INVOKE(f, args...) can convert to _Tp. | |
2865 | template<typename _Tp, typename = decltype(_S_conv<_Tp>(_S_get()))> | |
2866 | static true_type | |
2867 | _S_test(int); | |
2868 | ||
2869 | template<typename _Tp> | |
2870 | static false_type | |
2871 | _S_test(...); | |
2872 | ||
2873 | public: | |
2874 | using type = decltype(_S_test<_Ret>(1)); | |
2875 | }; | |
2876 | #pragma GCC diagnostic pop | |
2877 | ||
7dcc645c JW |
2878 | template<typename _Fn, typename... _ArgTypes> |
2879 | struct __is_invocable | |
2880 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type | |
42183d03 JW |
2881 | { }; |
2882 | ||
42183d03 JW |
2883 | template<typename _Fn, typename _Tp, typename... _Args> |
2884 | constexpr bool __call_is_nt(__invoke_memfun_ref) | |
2885 | { | |
2886 | using _Up = typename __inv_unwrap<_Tp>::type; | |
2887 | return noexcept((std::declval<_Up>().*std::declval<_Fn>())( | |
2888 | std::declval<_Args>()...)); | |
2889 | } | |
2890 | ||
2891 | template<typename _Fn, typename _Tp, typename... _Args> | |
2892 | constexpr bool __call_is_nt(__invoke_memfun_deref) | |
2893 | { | |
2894 | return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())( | |
2895 | std::declval<_Args>()...)); | |
2896 | } | |
2897 | ||
2898 | template<typename _Fn, typename _Tp> | |
2899 | constexpr bool __call_is_nt(__invoke_memobj_ref) | |
2900 | { | |
2901 | using _Up = typename __inv_unwrap<_Tp>::type; | |
2902 | return noexcept(std::declval<_Up>().*std::declval<_Fn>()); | |
2903 | } | |
2904 | ||
2905 | template<typename _Fn, typename _Tp> | |
2906 | constexpr bool __call_is_nt(__invoke_memobj_deref) | |
2907 | { | |
2908 | return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>()); | |
2909 | } | |
2910 | ||
2911 | template<typename _Fn, typename... _Args> | |
2912 | constexpr bool __call_is_nt(__invoke_other) | |
2913 | { | |
2914 | return noexcept(std::declval<_Fn>()(std::declval<_Args>()...)); | |
2915 | } | |
2916 | ||
7dcc645c | 2917 | template<typename _Result, typename _Fn, typename... _Args> |
42183d03 JW |
2918 | struct __call_is_nothrow |
2919 | : __bool_constant< | |
7dcc645c JW |
2920 | std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{}) |
2921 | > | |
42183d03 JW |
2922 | { }; |
2923 | ||
7dcc645c JW |
2924 | template<typename _Fn, typename... _Args> |
2925 | using __call_is_nothrow_ | |
2926 | = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>; | |
42183d03 | 2927 | |
7dcc645c JW |
2928 | // __is_nothrow_invocable (std::is_nothrow_invocable for C++11) |
2929 | template<typename _Fn, typename... _Args> | |
2930 | struct __is_nothrow_invocable | |
2931 | : __and_<__is_invocable<_Fn, _Args...>, | |
2932 | __call_is_nothrow_<_Fn, _Args...>>::type | |
42183d03 JW |
2933 | { }; |
2934 | ||
cc28d234 JW |
2935 | #pragma GCC diagnostic push |
2936 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | |
a73d2fa8 NDR |
2937 | struct __nonesuchbase {}; |
2938 | struct __nonesuch : private __nonesuchbase { | |
f524d5b3 VV |
2939 | ~__nonesuch() = delete; |
2940 | __nonesuch(__nonesuch const&) = delete; | |
2941 | void operator=(__nonesuch const&) = delete; | |
2942 | }; | |
cc28d234 | 2943 | #pragma GCC diagnostic pop |
f524d5b3 | 2944 | |
e641ee43 | 2945 | #if __cplusplus >= 201703L |
7dcc645c JW |
2946 | # define __cpp_lib_is_invocable 201703 |
2947 | ||
2948 | /// std::invoke_result | |
2949 | template<typename _Functor, typename... _ArgTypes> | |
2950 | struct invoke_result | |
2951 | : public __invoke_result<_Functor, _ArgTypes...> | |
2952 | { }; | |
2953 | ||
2954 | /// std::invoke_result_t | |
2955 | template<typename _Fn, typename... _Args> | |
2956 | using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; | |
42183d03 | 2957 | |
7dcc645c JW |
2958 | /// std::is_invocable |
2959 | template<typename _Fn, typename... _ArgTypes> | |
2960 | struct is_invocable | |
2961 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type | |
608a080c AP |
2962 | { |
2963 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), | |
2964 | "_Fn must be a complete class or an unbounded array"); | |
2965 | }; | |
42183d03 | 2966 | |
7dcc645c JW |
2967 | /// std::is_invocable_r |
2968 | template<typename _Ret, typename _Fn, typename... _ArgTypes> | |
2969 | struct is_invocable_r | |
2970 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type | |
608a080c AP |
2971 | { |
2972 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), | |
2973 | "_Fn must be a complete class or an unbounded array"); | |
2974 | }; | |
42183d03 | 2975 | |
7dcc645c JW |
2976 | /// std::is_nothrow_invocable |
2977 | template<typename _Fn, typename... _ArgTypes> | |
2978 | struct is_nothrow_invocable | |
2979 | : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>, | |
608a080c AP |
2980 | __call_is_nothrow_<_Fn, _ArgTypes...>>::type |
2981 | { | |
2982 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), | |
2983 | "_Fn must be a complete class or an unbounded array"); | |
2984 | }; | |
42183d03 | 2985 | |
c4b06e7f JW |
2986 | template<typename _Result, typename _Ret, typename = void> |
2987 | struct __is_nt_invocable_impl : false_type { }; | |
2988 | ||
2989 | template<typename _Result, typename _Ret> | |
2990 | struct __is_nt_invocable_impl<_Result, _Ret, | |
2991 | __void_t<typename _Result::type>> | |
91d01b33 | 2992 | : __or_<is_void<_Ret>, |
ce9f305e | 2993 | __is_nothrow_convertible<typename _Result::type, _Ret>> |
c4b06e7f JW |
2994 | { }; |
2995 | ||
7dcc645c JW |
2996 | /// std::is_nothrow_invocable_r |
2997 | template<typename _Ret, typename _Fn, typename... _ArgTypes> | |
2998 | struct is_nothrow_invocable_r | |
c4b06e7f | 2999 | : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>, |
7dcc645c | 3000 | __call_is_nothrow_<_Fn, _ArgTypes...>>::type |
42183d03 JW |
3001 | { }; |
3002 | ||
7dcc645c JW |
3003 | /// std::is_invocable_v |
3004 | template<typename _Fn, typename... _Args> | |
3005 | inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; | |
42183d03 | 3006 | |
7dcc645c JW |
3007 | /// std::is_nothrow_invocable_v |
3008 | template<typename _Fn, typename... _Args> | |
3009 | inline constexpr bool is_nothrow_invocable_v | |
3010 | = is_nothrow_invocable<_Fn, _Args...>::value; | |
42183d03 | 3011 | |
7dcc645c | 3012 | /// std::is_invocable_r_v |
ce9f305e | 3013 | template<typename _Ret, typename _Fn, typename... _Args> |
7dcc645c | 3014 | inline constexpr bool is_invocable_r_v |
ce9f305e | 3015 | = is_invocable_r<_Ret, _Fn, _Args...>::value; |
7dcc645c JW |
3016 | |
3017 | /// std::is_nothrow_invocable_r_v | |
ce9f305e | 3018 | template<typename _Ret, typename _Fn, typename... _Args> |
7dcc645c | 3019 | inline constexpr bool is_nothrow_invocable_r_v |
ce9f305e | 3020 | = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; |
7dcc645c | 3021 | #endif // C++17 |
42183d03 | 3022 | |
e641ee43 | 3023 | #if __cplusplus >= 201703L |
068c8ac1 | 3024 | # define __cpp_lib_type_trait_variable_templates 201510L |
137422c8 | 3025 | template <typename _Tp> |
288695f7 | 3026 | inline constexpr bool is_void_v = is_void<_Tp>::value; |
137422c8 | 3027 | template <typename _Tp> |
288695f7 | 3028 | inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; |
137422c8 | 3029 | template <typename _Tp> |
288695f7 | 3030 | inline constexpr bool is_integral_v = is_integral<_Tp>::value; |
137422c8 | 3031 | template <typename _Tp> |
288695f7 | 3032 | inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; |
137422c8 | 3033 | template <typename _Tp> |
288695f7 | 3034 | inline constexpr bool is_array_v = is_array<_Tp>::value; |
137422c8 | 3035 | template <typename _Tp> |
288695f7 | 3036 | inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; |
137422c8 | 3037 | template <typename _Tp> |
288695f7 DK |
3038 | inline constexpr bool is_lvalue_reference_v = |
3039 | is_lvalue_reference<_Tp>::value; | |
137422c8 | 3040 | template <typename _Tp> |
288695f7 DK |
3041 | inline constexpr bool is_rvalue_reference_v = |
3042 | is_rvalue_reference<_Tp>::value; | |
137422c8 | 3043 | template <typename _Tp> |
288695f7 | 3044 | inline constexpr bool is_member_object_pointer_v = |
137422c8 VV |
3045 | is_member_object_pointer<_Tp>::value; |
3046 | template <typename _Tp> | |
288695f7 | 3047 | inline constexpr bool is_member_function_pointer_v = |
137422c8 VV |
3048 | is_member_function_pointer<_Tp>::value; |
3049 | template <typename _Tp> | |
288695f7 | 3050 | inline constexpr bool is_enum_v = is_enum<_Tp>::value; |
137422c8 | 3051 | template <typename _Tp> |
288695f7 | 3052 | inline constexpr bool is_union_v = is_union<_Tp>::value; |
137422c8 | 3053 | template <typename _Tp> |
288695f7 | 3054 | inline constexpr bool is_class_v = is_class<_Tp>::value; |
137422c8 | 3055 | template <typename _Tp> |
288695f7 | 3056 | inline constexpr bool is_function_v = is_function<_Tp>::value; |
137422c8 | 3057 | template <typename _Tp> |
288695f7 | 3058 | inline constexpr bool is_reference_v = is_reference<_Tp>::value; |
137422c8 | 3059 | template <typename _Tp> |
288695f7 | 3060 | inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; |
137422c8 | 3061 | template <typename _Tp> |
288695f7 | 3062 | inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; |
137422c8 | 3063 | template <typename _Tp> |
288695f7 | 3064 | inline constexpr bool is_object_v = is_object<_Tp>::value; |
137422c8 | 3065 | template <typename _Tp> |
288695f7 | 3066 | inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; |
137422c8 | 3067 | template <typename _Tp> |
288695f7 | 3068 | inline constexpr bool is_compound_v = is_compound<_Tp>::value; |
137422c8 | 3069 | template <typename _Tp> |
288695f7 | 3070 | inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; |
137422c8 | 3071 | template <typename _Tp> |
288695f7 | 3072 | inline constexpr bool is_const_v = is_const<_Tp>::value; |
137422c8 | 3073 | template <typename _Tp> |
288695f7 | 3074 | inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; |
137422c8 | 3075 | template <typename _Tp> |
288695f7 | 3076 | inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; |
137422c8 | 3077 | template <typename _Tp> |
288695f7 DK |
3078 | inline constexpr bool is_trivially_copyable_v = |
3079 | is_trivially_copyable<_Tp>::value; | |
137422c8 | 3080 | template <typename _Tp> |
288695f7 | 3081 | inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; |
caa39b2e JW |
3082 | #pragma GCC diagnostic push |
3083 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
137422c8 | 3084 | template <typename _Tp> |
1a6c5064 | 3085 | _GLIBCXX20_DEPRECATED("use is_standard_layout_v && is_trivial_v instead") |
288695f7 | 3086 | inline constexpr bool is_pod_v = is_pod<_Tp>::value; |
caa39b2e | 3087 | #pragma GCC diagnostic pop |
137422c8 | 3088 | template <typename _Tp> |
288695f7 | 3089 | inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; |
137422c8 | 3090 | template <typename _Tp> |
288695f7 | 3091 | inline constexpr bool is_empty_v = is_empty<_Tp>::value; |
137422c8 | 3092 | template <typename _Tp> |
288695f7 | 3093 | inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; |
137422c8 | 3094 | template <typename _Tp> |
288695f7 | 3095 | inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; |
137422c8 | 3096 | template <typename _Tp> |
288695f7 | 3097 | inline constexpr bool is_final_v = is_final<_Tp>::value; |
137422c8 | 3098 | template <typename _Tp> |
288695f7 | 3099 | inline constexpr bool is_signed_v = is_signed<_Tp>::value; |
137422c8 | 3100 | template <typename _Tp> |
288695f7 | 3101 | inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; |
137422c8 | 3102 | template <typename _Tp, typename... _Args> |
288695f7 DK |
3103 | inline constexpr bool is_constructible_v = |
3104 | is_constructible<_Tp, _Args...>::value; | |
137422c8 | 3105 | template <typename _Tp> |
288695f7 | 3106 | inline constexpr bool is_default_constructible_v = |
137422c8 VV |
3107 | is_default_constructible<_Tp>::value; |
3108 | template <typename _Tp> | |
288695f7 DK |
3109 | inline constexpr bool is_copy_constructible_v = |
3110 | is_copy_constructible<_Tp>::value; | |
137422c8 | 3111 | template <typename _Tp> |
288695f7 DK |
3112 | inline constexpr bool is_move_constructible_v = |
3113 | is_move_constructible<_Tp>::value; | |
137422c8 | 3114 | template <typename _Tp, typename _Up> |
288695f7 | 3115 | inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; |
137422c8 | 3116 | template <typename _Tp> |
288695f7 | 3117 | inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; |
137422c8 | 3118 | template <typename _Tp> |
288695f7 | 3119 | inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; |
137422c8 | 3120 | template <typename _Tp> |
288695f7 | 3121 | inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; |
137422c8 | 3122 | template <typename _Tp, typename... _Args> |
288695f7 | 3123 | inline constexpr bool is_trivially_constructible_v = |
137422c8 VV |
3124 | is_trivially_constructible<_Tp, _Args...>::value; |
3125 | template <typename _Tp> | |
288695f7 | 3126 | inline constexpr bool is_trivially_default_constructible_v = |
137422c8 VV |
3127 | is_trivially_default_constructible<_Tp>::value; |
3128 | template <typename _Tp> | |
288695f7 | 3129 | inline constexpr bool is_trivially_copy_constructible_v = |
137422c8 VV |
3130 | is_trivially_copy_constructible<_Tp>::value; |
3131 | template <typename _Tp> | |
288695f7 | 3132 | inline constexpr bool is_trivially_move_constructible_v = |
137422c8 VV |
3133 | is_trivially_move_constructible<_Tp>::value; |
3134 | template <typename _Tp, typename _Up> | |
288695f7 | 3135 | inline constexpr bool is_trivially_assignable_v = |
137422c8 VV |
3136 | is_trivially_assignable<_Tp, _Up>::value; |
3137 | template <typename _Tp> | |
288695f7 | 3138 | inline constexpr bool is_trivially_copy_assignable_v = |
137422c8 VV |
3139 | is_trivially_copy_assignable<_Tp>::value; |
3140 | template <typename _Tp> | |
288695f7 | 3141 | inline constexpr bool is_trivially_move_assignable_v = |
137422c8 VV |
3142 | is_trivially_move_assignable<_Tp>::value; |
3143 | template <typename _Tp> | |
288695f7 | 3144 | inline constexpr bool is_trivially_destructible_v = |
137422c8 VV |
3145 | is_trivially_destructible<_Tp>::value; |
3146 | template <typename _Tp, typename... _Args> | |
288695f7 | 3147 | inline constexpr bool is_nothrow_constructible_v = |
137422c8 VV |
3148 | is_nothrow_constructible<_Tp, _Args...>::value; |
3149 | template <typename _Tp> | |
288695f7 | 3150 | inline constexpr bool is_nothrow_default_constructible_v = |
137422c8 VV |
3151 | is_nothrow_default_constructible<_Tp>::value; |
3152 | template <typename _Tp> | |
288695f7 | 3153 | inline constexpr bool is_nothrow_copy_constructible_v = |
137422c8 VV |
3154 | is_nothrow_copy_constructible<_Tp>::value; |
3155 | template <typename _Tp> | |
288695f7 | 3156 | inline constexpr bool is_nothrow_move_constructible_v = |
137422c8 VV |
3157 | is_nothrow_move_constructible<_Tp>::value; |
3158 | template <typename _Tp, typename _Up> | |
288695f7 | 3159 | inline constexpr bool is_nothrow_assignable_v = |
137422c8 VV |
3160 | is_nothrow_assignable<_Tp, _Up>::value; |
3161 | template <typename _Tp> | |
288695f7 | 3162 | inline constexpr bool is_nothrow_copy_assignable_v = |
137422c8 VV |
3163 | is_nothrow_copy_assignable<_Tp>::value; |
3164 | template <typename _Tp> | |
288695f7 | 3165 | inline constexpr bool is_nothrow_move_assignable_v = |
137422c8 VV |
3166 | is_nothrow_move_assignable<_Tp>::value; |
3167 | template <typename _Tp> | |
288695f7 | 3168 | inline constexpr bool is_nothrow_destructible_v = |
137422c8 VV |
3169 | is_nothrow_destructible<_Tp>::value; |
3170 | template <typename _Tp> | |
288695f7 | 3171 | inline constexpr bool has_virtual_destructor_v = |
137422c8 VV |
3172 | has_virtual_destructor<_Tp>::value; |
3173 | template <typename _Tp> | |
288695f7 | 3174 | inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; |
137422c8 | 3175 | template <typename _Tp> |
288695f7 | 3176 | inline constexpr size_t rank_v = rank<_Tp>::value; |
137422c8 | 3177 | template <typename _Tp, unsigned _Idx = 0> |
288695f7 | 3178 | inline constexpr size_t extent_v = extent<_Tp, _Idx>::value; |
44af818f | 3179 | #ifdef _GLIBCXX_BUILTIN_IS_SAME_AS |
137422c8 | 3180 | template <typename _Tp, typename _Up> |
44af818f JW |
3181 | inline constexpr bool is_same_v = _GLIBCXX_BUILTIN_IS_SAME_AS(_Tp, _Up); |
3182 | #else | |
3183 | template <typename _Tp, typename _Up> | |
3184 | inline constexpr bool is_same_v = std::is_same<_Tp, _Up>::value; | |
3185 | #endif | |
137422c8 | 3186 | template <typename _Base, typename _Derived> |
288695f7 | 3187 | inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; |
137422c8 | 3188 | template <typename _From, typename _To> |
288695f7 | 3189 | inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; |
873c7d5a | 3190 | |
2d763763 | 3191 | #ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP |
873c7d5a JW |
3192 | # define __cpp_lib_has_unique_object_representations 201606 |
3193 | /// has_unique_object_representations | |
3194 | template<typename _Tp> | |
3195 | struct has_unique_object_representations | |
3196 | : bool_constant<__has_unique_object_representations( | |
3197 | remove_cv_t<remove_all_extents_t<_Tp>> | |
3198 | )> | |
608a080c AP |
3199 | { |
3200 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
3201 | "template argument must be a complete class or an unbounded array"); | |
3202 | }; | |
b0e63d94 JW |
3203 | |
3204 | template<typename _Tp> | |
3205 | inline constexpr bool has_unique_object_representations_v | |
3206 | = has_unique_object_representations<_Tp>::value; | |
1f5700e9 | 3207 | #endif |
e2ac6765 | 3208 | |
afa56c17 | 3209 | #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE |
ff273400 | 3210 | # define __cpp_lib_is_aggregate 201703 |
e2ac6765 VV |
3211 | /// is_aggregate |
3212 | template<typename _Tp> | |
3213 | struct is_aggregate | |
608a080c | 3214 | : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> |
209ee624 | 3215 | { }; |
e2ac6765 VV |
3216 | |
3217 | /// is_aggregate_v | |
3218 | template<typename _Tp> | |
3219 | inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; | |
3220 | #endif | |
137422c8 | 3221 | #endif // C++17 |
6b9539e2 | 3222 | |
e641ee43 | 3223 | #if __cplusplus > 201703L |
6791489e JW |
3224 | /// Remove references and cv-qualifiers. |
3225 | template<typename _Tp> | |
3226 | struct remove_cvref | |
3227 | { | |
3228 | using type = __remove_cvref_t<_Tp>; | |
3229 | }; | |
3230 | ||
3231 | template<typename _Tp> | |
3232 | using remove_cvref_t = __remove_cvref_t<_Tp>; | |
3233 | ||
ee896276 JW |
3234 | /// Identity metafunction. |
3235 | template<typename _Tp> | |
3236 | struct type_identity { using type = _Tp; }; | |
3237 | ||
3238 | template<typename _Tp> | |
3239 | using type_identity_t = typename type_identity<_Tp>::type; | |
3240 | ||
3d18dc9d JW |
3241 | /// Unwrap a reference_wrapper |
3242 | template<typename _Tp> | |
3243 | struct unwrap_reference { using type = _Tp; }; | |
3244 | ||
3245 | template<typename _Tp> | |
3246 | struct unwrap_reference<reference_wrapper<_Tp>> { using type = _Tp&; }; | |
3247 | ||
82e8c3da JW |
3248 | template<typename _Tp> |
3249 | using unwrap_reference_t = typename unwrap_reference<_Tp>::type; | |
3250 | ||
3d18dc9d JW |
3251 | /// Decay type and if it's a reference_wrapper, unwrap it |
3252 | template<typename _Tp> | |
82e8c3da | 3253 | struct unwrap_ref_decay { using type = unwrap_reference_t<decay_t<_Tp>>; }; |
3d18dc9d JW |
3254 | |
3255 | template<typename _Tp> | |
3256 | using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; | |
3257 | ||
46610940 JW |
3258 | #define __cpp_lib_bounded_array_traits 201902L |
3259 | ||
28d85efb JW |
3260 | /// True for a type that is an array of known bound. |
3261 | template<typename _Tp> | |
3262 | struct is_bounded_array | |
3263 | : public __is_array_known_bounds<_Tp> | |
3264 | { }; | |
3265 | ||
3266 | /// True for a type that is an array of unknown bound. | |
3267 | template<typename _Tp> | |
3268 | struct is_unbounded_array | |
3269 | : public __is_array_unknown_bounds<_Tp> | |
3270 | { }; | |
3271 | ||
3272 | template<typename _Tp> | |
3273 | inline constexpr bool is_bounded_array_v | |
3274 | = is_bounded_array<_Tp>::value; | |
3275 | ||
3276 | template<typename _Tp> | |
3277 | inline constexpr bool is_unbounded_array_v | |
3278 | = is_unbounded_array<_Tp>::value; | |
3279 | ||
0d7924f2 | 3280 | #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED |
134a6f7b | 3281 | |
8aa1550e | 3282 | #define __cpp_lib_is_constant_evaluated 201811L |
134a6f7b | 3283 | |
0d7924f2 JJ |
3284 | constexpr inline bool |
3285 | is_constant_evaluated() noexcept | |
3286 | { return __builtin_is_constant_evaluated(); } | |
3287 | #endif | |
3288 | ||
0f8b14ee JW |
3289 | template<typename _From, typename _To> |
3290 | using __copy_cv = typename __match_cv_qualifiers<_From, _To>::__type; | |
3291 | ||
3292 | template<typename _Xp, typename _Yp> | |
3293 | using __cond_res | |
3294 | = decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()()); | |
3295 | ||
3296 | template<typename _Ap, typename _Bp, typename = void> | |
3297 | struct __common_ref_impl | |
3298 | { }; | |
3299 | ||
3300 | // [meta.trans.other], COMMON-REF(A, B) | |
3301 | template<typename _Ap, typename _Bp> | |
3302 | using __common_ref = typename __common_ref_impl<_Ap, _Bp>::type; | |
3303 | ||
3304 | // If A and B are both lvalue reference types, ... | |
3305 | template<typename _Xp, typename _Yp> | |
3306 | struct __common_ref_impl<_Xp&, _Yp&, | |
3307 | __void_t<__cond_res<__copy_cv<_Xp, _Yp>&, __copy_cv<_Yp, _Xp>&>>> | |
3308 | { using type = __cond_res<__copy_cv<_Xp, _Yp>&, __copy_cv<_Yp, _Xp>&>; }; | |
3309 | ||
3310 | // let C be remove_reference_t<COMMON-REF(X&, Y&)>&& | |
3311 | template<typename _Xp, typename _Yp> | |
3312 | using __common_ref_C = remove_reference_t<__common_ref<_Xp&, _Yp&>>&&; | |
3313 | ||
3314 | // If A and B are both rvalue reference types, ... | |
3315 | template<typename _Xp, typename _Yp> | |
3316 | struct __common_ref_impl<_Xp&&, _Yp&&, | |
3317 | _Require<is_convertible<_Xp&&, __common_ref_C<_Xp, _Yp>>, | |
3318 | is_convertible<_Yp&&, __common_ref_C<_Xp, _Yp>>>> | |
3319 | { using type = __common_ref_C<_Xp, _Yp>; }; | |
3320 | ||
3321 | // let D be COMMON-REF(const X&, Y&) | |
3322 | template<typename _Xp, typename _Yp> | |
3323 | using __common_ref_D = __common_ref<const _Xp&, _Yp&>; | |
3324 | ||
3325 | // If A is an rvalue reference and B is an lvalue reference, ... | |
3326 | template<typename _Xp, typename _Yp> | |
3327 | struct __common_ref_impl<_Xp&&, _Yp&, | |
3328 | _Require<is_convertible<_Xp&&, __common_ref_D<_Xp, _Yp>>>> | |
3329 | { using type = __common_ref_D<_Xp, _Yp>; }; | |
3330 | ||
3331 | // If A is an lvalue reference and B is an rvalue reference, ... | |
3332 | template<typename _Xp, typename _Yp> | |
3333 | struct __common_ref_impl<_Xp&, _Yp&&> | |
3334 | : __common_ref_impl<_Yp&&, _Xp&> | |
3335 | { }; | |
3336 | ||
3337 | template<typename _Tp, typename _Up, | |
3338 | template<typename> class _TQual, template<typename> class _UQual> | |
3339 | struct basic_common_reference | |
3340 | { }; | |
3341 | ||
3342 | template<typename _Tp> | |
3343 | struct __xref | |
3344 | { template<typename _Up> using __type = __copy_cv<_Tp, _Up>; }; | |
3345 | ||
3346 | template<typename _Tp> | |
3347 | struct __xref<_Tp&> | |
3348 | { template<typename _Up> using __type = __copy_cv<_Tp, _Up>&; }; | |
3349 | ||
3350 | template<typename _Tp> | |
3351 | struct __xref<_Tp&&> | |
3352 | { template<typename _Up> using __type = __copy_cv<_Tp, _Up>&&; }; | |
3353 | ||
3354 | template<typename _Tp1, typename _Tp2> | |
3355 | using __basic_common_ref | |
3356 | = typename basic_common_reference<remove_cvref_t<_Tp1>, | |
3357 | remove_cvref_t<_Tp2>, | |
3358 | __xref<_Tp1>::template __type, | |
3359 | __xref<_Tp2>::template __type>::type; | |
3360 | ||
3361 | template<typename... _Tp> | |
3362 | struct common_reference; | |
3363 | ||
3364 | template<typename... _Tp> | |
3365 | using common_reference_t = typename common_reference<_Tp...>::type; | |
3366 | ||
3367 | // If sizeof...(T) is zero, there shall be no member type. | |
3368 | template<> | |
3369 | struct common_reference<> | |
3370 | { }; | |
3371 | ||
3372 | // If sizeof...(T) is one ... | |
3373 | template<typename _Tp0> | |
3374 | struct common_reference<_Tp0> | |
3375 | { using type = _Tp0; }; | |
3376 | ||
3377 | template<typename _Tp1, typename _Tp2, int _Bullet = 1, typename = void> | |
3378 | struct __common_reference_impl | |
3379 | : __common_reference_impl<_Tp1, _Tp2, _Bullet + 1> | |
3380 | { }; | |
3381 | ||
3382 | // If sizeof...(T) is two ... | |
3383 | template<typename _Tp1, typename _Tp2> | |
3384 | struct common_reference<_Tp1, _Tp2> | |
3385 | : __common_reference_impl<_Tp1, _Tp2> | |
3386 | { }; | |
3387 | ||
3388 | // If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, ... | |
3389 | template<typename _Tp1, typename _Tp2> | |
3390 | struct __common_reference_impl<_Tp1&, _Tp2&, 1, | |
3391 | void_t<__common_ref<_Tp1&, _Tp2&>>> | |
3392 | { using type = __common_ref<_Tp1&, _Tp2&>; }; | |
3393 | ||
3394 | template<typename _Tp1, typename _Tp2> | |
3395 | struct __common_reference_impl<_Tp1&&, _Tp2&&, 1, | |
3396 | void_t<__common_ref<_Tp1&&, _Tp2&&>>> | |
3397 | { using type = __common_ref<_Tp1&&, _Tp2&&>; }; | |
3398 | ||
3399 | template<typename _Tp1, typename _Tp2> | |
3400 | struct __common_reference_impl<_Tp1&, _Tp2&&, 1, | |
3401 | void_t<__common_ref<_Tp1&, _Tp2&&>>> | |
3402 | { using type = __common_ref<_Tp1&, _Tp2&&>; }; | |
3403 | ||
3404 | template<typename _Tp1, typename _Tp2> | |
3405 | struct __common_reference_impl<_Tp1&&, _Tp2&, 1, | |
3406 | void_t<__common_ref<_Tp1&&, _Tp2&>>> | |
3407 | { using type = __common_ref<_Tp1&&, _Tp2&>; }; | |
3408 | ||
3409 | // Otherwise, if basic_common_reference<...>::type is well-formed, ... | |
3410 | template<typename _Tp1, typename _Tp2> | |
3411 | struct __common_reference_impl<_Tp1, _Tp2, 2, | |
3412 | void_t<__basic_common_ref<_Tp1, _Tp2>>> | |
3413 | { using type = __basic_common_ref<_Tp1, _Tp2>; }; | |
3414 | ||
3415 | // Otherwise, if COND-RES(T1, T2) is well-formed, ... | |
3416 | template<typename _Tp1, typename _Tp2> | |
3417 | struct __common_reference_impl<_Tp1, _Tp2, 3, | |
3418 | void_t<__cond_res<_Tp1, _Tp2>>> | |
3419 | { using type = __cond_res<_Tp1, _Tp2>; }; | |
3420 | ||
3421 | // Otherwise, if common_type_t<T1, T2> is well-formed, ... | |
3422 | template<typename _Tp1, typename _Tp2> | |
3423 | struct __common_reference_impl<_Tp1, _Tp2, 4, | |
3424 | void_t<common_type_t<_Tp1, _Tp2>>> | |
3425 | { using type = common_type_t<_Tp1, _Tp2>; }; | |
3426 | ||
3427 | // Otherwise, there shall be no member type. | |
3428 | template<typename _Tp1, typename _Tp2> | |
3429 | struct __common_reference_impl<_Tp1, _Tp2, 5, void> | |
3430 | { }; | |
3431 | ||
3432 | // Otherwise, if sizeof...(T) is greater than two, ... | |
3433 | template<typename _Tp1, typename _Tp2, typename... _Rest> | |
3434 | struct common_reference<_Tp1, _Tp2, _Rest...> | |
3435 | : __common_type_fold<common_reference<_Tp1, _Tp2>, | |
3436 | __common_type_pack<_Rest...>> | |
3437 | { }; | |
3438 | ||
3439 | // Reuse __common_type_fold for common_reference<T1, T2, Rest...> | |
3440 | template<typename _Tp1, typename _Tp2, typename... _Rest> | |
3441 | struct __common_type_fold<common_reference<_Tp1, _Tp2>, | |
3442 | __common_type_pack<_Rest...>, | |
3443 | void_t<common_reference_t<_Tp1, _Tp2>>> | |
3444 | : public common_reference<common_reference_t<_Tp1, _Tp2>, _Rest...> | |
3445 | { }; | |
3446 | ||
e641ee43 JW |
3447 | #endif // C++2a |
3448 | ||
12ffa228 | 3449 | _GLIBCXX_END_NAMESPACE_VERSION |
c0ffa2ba | 3450 | } // namespace std |
7b50cdef | 3451 | |
734f5023 | 3452 | #endif // C++11 |
57317d2a | 3453 | |
7274deff | 3454 | #endif // _GLIBCXX_TYPE_TRAITS |