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