Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/c++/13/type_traits
$ cat -n /usr/include/c++/13/type_traits 1 // C++11
-*- C++ -*- 2 3 // Copyright (C) 2007-2023 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 //
. 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
36 #else 37 38 #include
39 40 namespace std _GLIBCXX_VISIBILITY(default) 41 { 42 _GLIBCXX_BEGIN_NAMESPACE_VERSION 43 44 template
45 class reference_wrapper; 46 47 /** 48 * @defgroup metaprogramming Metaprogramming 49 * @ingroup utilities 50 * 51 * Template utilities for compile-time introspection and modification, 52 * including type classification traits, type property inspection traits 53 * and type transformation traits. 54 * 55 * @since C++11 56 * 57 * @{ 58 */ 59 60 /// integral_constant 61 template
62 struct integral_constant 63 { 64 static constexpr _Tp value = __v; 65 typedef _Tp value_type; 66 typedef integral_constant<_Tp, __v> type; 67 constexpr operator value_type() const noexcept { return value; } 68 #if __cplusplus > 201103L 69 70 #define __cpp_lib_integral_constant_callable 201304L 71 72 constexpr value_type operator()() const noexcept { return value; } 73 #endif 74 }; 75 76 #if ! __cpp_inline_variables 77 template
78 constexpr _Tp integral_constant<_Tp, __v>::value; 79 #endif 80 81 /// The type used as a compile-time boolean with true value. 82 using true_type = integral_constant
; 83 84 /// The type used as a compile-time boolean with false value. 85 using false_type = integral_constant
; 86 87 /// @cond undocumented 88 /// bool_constant for C++11 89 template
90 using __bool_constant = integral_constant
; 91 /// @endcond 92 93 #if __cplusplus >= 201703L 94 # define __cpp_lib_bool_constant 201505L 95 /// Alias template for compile-time boolean constant types. 96 /// @since C++17 97 template
98 using bool_constant = integral_constant
; 99 #endif 100 101 // Metaprogramming helper types. 102 103 // Primary template. 104 /// Define a member typedef `type` only if a boolean constant is true. 105 template
106 struct enable_if 107 { }; 108 109 // Partial specialization for true. 110 template
111 struct enable_if
112 { typedef _Tp type; }; 113 114 // __enable_if_t (std::enable_if_t for C++11) 115 template
116 using __enable_if_t = typename enable_if<_Cond, _Tp>::type; 117 118 template
119 struct __conditional 120 { 121 template
122 using type = _Tp; 123 }; 124 125 template<> 126 struct __conditional
127 { 128 template
129 using type = _Up; 130 }; 131 132 // More efficient version of std::conditional_t for internal use (and C++11) 133 template
134 using __conditional_t 135 = typename __conditional<_Cond>::template type<_If, _Else>; 136 137 /// @cond undocumented 138 template
139 struct __type_identity 140 { using type = _Type; }; 141 142 template
143 using __type_identity_t = typename __type_identity<_Tp>::type; 144 145 namespace __detail 146 { 147 // A variadic alias template that resolves to its first argument. 148 template
149 using __first_t = _Tp; 150 151 // These are deliberately not defined. 152 template
153 auto __or_fn(int) -> __first_t
...>; 155 156 template
157 auto __or_fn(...) -> true_type; 158 159 template
160 auto __and_fn(int) -> __first_t
...>; 162 163 template
164 auto __and_fn(...) -> false_type; 165 } // namespace detail 166 167 // Like C++17 std::dis/conjunction, but usable in C++11 and resolves 168 // to either true_type or false_type which allows for a more efficient 169 // implementation that avoids recursive class template instantiation. 170 template
171 struct __or_ 172 : decltype(__detail::__or_fn<_Bn...>(0)) 173 { }; 174 175 template
176 struct __and_ 177 : decltype(__detail::__and_fn<_Bn...>(0)) 178 { }; 179 180 template
181 struct __not_ 182 : __bool_constant 183 { }; 184 /// @endcond 185 186 #if __cplusplus >= 201703L 187 188 /// @cond undocumented 189 template
190 inline constexpr bool __or_v = __or_<_Bn...>::value; 191 template
192 inline constexpr bool __and_v = __and_<_Bn...>::value; 193 194 namespace __detail 195 { 196 template
197 struct __disjunction_impl 198 { using type = _B1; }; 199 200 template
201 struct __disjunction_impl<__enable_if_t, _B1, _B2, _Bn...> 202 { using type = typename __disjunction_impl
::type; }; 203 204 template
205 struct __conjunction_impl 206 { using type = _B1; }; 207 208 template
209 struct __conjunction_impl<__enable_if_t
, _B1, _B2, _Bn...> 210 { using type = typename __conjunction_impl
::type; }; 211 } // namespace __detail 212 /// @endcond 213 214 #define __cpp_lib_logical_traits 201510L 215 216 template
217 struct conjunction 218 : __detail::__conjunction_impl
::type 219 { }; 220 221 template<> 222 struct conjunction<> 223 : true_type 224 { }; 225 226 template
227 struct disjunction 228 : __detail::__disjunction_impl
::type 229 { }; 230 231 template<> 232 struct disjunction<> 233 : false_type 234 { }; 235 236 template
237 struct negation 238 : __not_<_Pp>::type 239 { }; 240 241 /** @ingroup variable_templates 242 * @{ 243 */ 244 template
245 inline constexpr bool conjunction_v = conjunction<_Bn...>::value; 246 247 template
248 inline constexpr bool disjunction_v = disjunction<_Bn...>::value; 249 250 template
251 inline constexpr bool negation_v = negation<_Pp>::value; 252 /// @} 253 254 #endif // C++17 255 256 // Forward declarations 257 template
258 struct is_reference; 259 template
260 struct is_function; 261 template
262 struct is_void; 263 template
264 struct remove_cv; 265 template
266 struct is_const; 267 268 /// @cond undocumented 269 template
270 struct __is_array_unknown_bounds; 271 272 // Helper functions that return false_type for incomplete classes, 273 // incomplete unions and arrays of known bound from those. 274 275 template
276 constexpr true_type __is_complete_or_unbounded(__type_identity<_Tp>) 277 { return {}; } 278 279 template
281 constexpr typename __or_< 282 is_reference<_NestedType>, 283 is_function<_NestedType>, 284 is_void<_NestedType>, 285 __is_array_unknown_bounds<_NestedType> 286 >::type __is_complete_or_unbounded(_TypeIdentity) 287 { return {}; } 288 289 // __remove_cv_t (std::remove_cv_t for C++11). 290 template
291 using __remove_cv_t = typename remove_cv<_Tp>::type; 292 /// @endcond 293 294 // Primary type categories. 295 296 /// is_void 297 template
298 struct is_void 299 : public false_type { }; 300 301 template<> 302 struct is_void
303 : public true_type { }; 304 305 template<> 306 struct is_void
307 : public true_type { }; 308 309 template<> 310 struct is_void
311 : public true_type { }; 312 313 template<> 314 struct is_void
315 : public true_type { }; 316 317 /// @cond undocumented 318 template
319 struct __is_integral_helper 320 : public false_type { }; 321 322 template<> 323 struct __is_integral_helper
324 : public true_type { }; 325 326 template<> 327 struct __is_integral_helper
328 : public true_type { }; 329 330 template<> 331 struct __is_integral_helper
332 : public true_type { }; 333 334 template<> 335 struct __is_integral_helper
336 : public true_type { }; 337 338 // We want is_integral
to be true (and make_signed/unsigned to work) 339 // even when libc doesn't provide working
and related functions, 340 // so don't check _GLIBCXX_USE_WCHAR_T here. 341 template<> 342 struct __is_integral_helper
343 : public true_type { }; 344 345 #ifdef _GLIBCXX_USE_CHAR8_T 346 template<> 347 struct __is_integral_helper
348 : public true_type { }; 349 #endif 350 351 template<> 352 struct __is_integral_helper
353 : public true_type { }; 354 355 template<> 356 struct __is_integral_helper
357 : public true_type { }; 358 359 template<> 360 struct __is_integral_helper
361 : public true_type { }; 362 363 template<> 364 struct __is_integral_helper
365 : public true_type { }; 366 367 template<> 368 struct __is_integral_helper
369 : public true_type { }; 370 371 template<> 372 struct __is_integral_helper
373 : public true_type { }; 374 375 template<> 376 struct __is_integral_helper
377 : public true_type { }; 378 379 template<> 380 struct __is_integral_helper
381 : public true_type { }; 382 383 template<> 384 struct __is_integral_helper
385 : public true_type { }; 386 387 template<> 388 struct __is_integral_helper
389 : public true_type { }; 390 391 // Conditionalizing on __STRICT_ANSI__ here will break any port that 392 // uses one of these types for size_t. 393 #if defined(__GLIBCXX_TYPE_INT_N_0) 394 __extension__ 395 template<> 396 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0> 397 : public true_type { }; 398 399 __extension__ 400 template<> 401 struct __is_integral_helper
402 : public true_type { }; 403 #endif 404 #if defined(__GLIBCXX_TYPE_INT_N_1) 405 __extension__ 406 template<> 407 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1> 408 : public true_type { }; 409 410 __extension__ 411 template<> 412 struct __is_integral_helper
413 : public true_type { }; 414 #endif 415 #if defined(__GLIBCXX_TYPE_INT_N_2) 416 __extension__ 417 template<> 418 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2> 419 : public true_type { }; 420 421 __extension__ 422 template<> 423 struct __is_integral_helper
424 : public true_type { }; 425 #endif 426 #if defined(__GLIBCXX_TYPE_INT_N_3) 427 __extension__ 428 template<> 429 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3> 430 : public true_type { }; 431 432 __extension__ 433 template<> 434 struct __is_integral_helper
435 : public true_type { }; 436 #endif 437 /// @endcond 438 439 /// is_integral 440 template
441 struct is_integral 442 : public __is_integral_helper<__remove_cv_t<_Tp>>::type 443 { }; 444 445 /// @cond undocumented 446 template
447 struct __is_floating_point_helper 448 : public false_type { }; 449 450 template<> 451 struct __is_floating_point_helper
452 : public true_type { }; 453 454 template<> 455 struct __is_floating_point_helper
456 : public true_type { }; 457 458 template<> 459 struct __is_floating_point_helper
460 : public true_type { }; 461 462 #ifdef __STDCPP_FLOAT16_T__ 463 template<> 464 struct __is_floating_point_helper<_Float16> 465 : public true_type { }; 466 #endif 467 468 #ifdef __STDCPP_FLOAT32_T__ 469 template<> 470 struct __is_floating_point_helper<_Float32> 471 : public true_type { }; 472 #endif 473 474 #ifdef __STDCPP_FLOAT64_T__ 475 template<> 476 struct __is_floating_point_helper<_Float64> 477 : public true_type { }; 478 #endif 479 480 #ifdef __STDCPP_FLOAT128_T__ 481 template<> 482 struct __is_floating_point_helper<_Float128> 483 : public true_type { }; 484 #endif 485 486 #ifdef __STDCPP_BFLOAT16_T__ 487 template<> 488 struct __is_floating_point_helper<__gnu_cxx::__bfloat16_t> 489 : public true_type { }; 490 #endif 491 492 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) && !defined(__CUDACC__) 493 template<> 494 struct __is_floating_point_helper<__float128> 495 : public true_type { }; 496 #endif 497 /// @endcond 498 499 /// is_floating_point 500 template
501 struct is_floating_point 502 : public __is_floating_point_helper<__remove_cv_t<_Tp>>::type 503 { }; 504 505 /// is_array 506 template
507 struct is_array 508 : public false_type { }; 509 510 template
511 struct is_array<_Tp[_Size]> 512 : public true_type { }; 513 514 template
515 struct is_array<_Tp[]> 516 : public true_type { }; 517 518 template
519 struct __is_pointer_helper 520 : public false_type { }; 521 522 template
523 struct __is_pointer_helper<_Tp*> 524 : public true_type { }; 525 526 /// is_pointer 527 template
528 struct is_pointer 529 : public __is_pointer_helper<__remove_cv_t<_Tp>>::type 530 { }; 531 532 /// is_lvalue_reference 533 template
534 struct is_lvalue_reference 535 : public false_type { }; 536 537 template
538 struct is_lvalue_reference<_Tp&> 539 : public true_type { }; 540 541 /// is_rvalue_reference 542 template
543 struct is_rvalue_reference 544 : public false_type { }; 545 546 template
547 struct is_rvalue_reference<_Tp&&> 548 : public true_type { }; 549 550 template
551 struct __is_member_object_pointer_helper 552 : public false_type { }; 553 554 template
555 struct __is_member_object_pointer_helper<_Tp _Cp::*> 556 : public __not_
>::type { }; 557 558 /// is_member_object_pointer 559 template
560 struct is_member_object_pointer 561 : public __is_member_object_pointer_helper<__remove_cv_t<_Tp>>::type 562 { }; 563 564 template
565 struct __is_member_function_pointer_helper 566 : public false_type { }; 567 568 template
569 struct __is_member_function_pointer_helper<_Tp _Cp::*> 570 : public is_function<_Tp>::type { }; 571 572 /// is_member_function_pointer 573 template
574 struct is_member_function_pointer 575 : public __is_member_function_pointer_helper<__remove_cv_t<_Tp>>::type 576 { }; 577 578 /// is_enum 579 template
580 struct is_enum 581 : public integral_constant
582 { }; 583 584 /// is_union 585 template
586 struct is_union 587 : public integral_constant
588 { }; 589 590 /// is_class 591 template
592 struct is_class 593 : public integral_constant
594 { }; 595 596 /// is_function 597 template
598 struct is_function 599 : public __bool_constant::value> { }; 600 601 template
602 struct is_function<_Tp&> 603 : public false_type { }; 604 605 template
606 struct is_function<_Tp&&> 607 : public false_type { }; 608 609 #define __cpp_lib_is_null_pointer 201309L 610 611 /// is_null_pointer (LWG 2247). 612 template
613 struct is_null_pointer 614 : public false_type { }; 615 616 template<> 617 struct is_null_pointer
618 : public true_type { }; 619 620 template<> 621 struct is_null_pointer
622 : public true_type { }; 623 624 template<> 625 struct is_null_pointer
626 : public true_type { }; 627 628 template<> 629 struct is_null_pointer
630 : public true_type { }; 631 632 /// __is_nullptr_t (deprecated extension). 633 /// @deprecated Non-standard. Use `is_null_pointer` instead. 634 template
635 struct __is_nullptr_t 636 : public is_null_pointer<_Tp> 637 { } _GLIBCXX_DEPRECATED_SUGGEST("std::is_null_pointer"); 638 639 // Composite type categories. 640 641 /// is_reference 642 template
643 struct is_reference 644 : public false_type 645 { }; 646 647 template
648 struct is_reference<_Tp&> 649 : public true_type 650 { }; 651 652 template
653 struct is_reference<_Tp&&> 654 : public true_type 655 { }; 656 657 /// is_arithmetic 658 template
659 struct is_arithmetic 660 : public __or_
, is_floating_point<_Tp>>::type 661 { }; 662 663 /// is_fundamental 664 template
665 struct is_fundamental 666 : public __or_
, is_void<_Tp>, 667 is_null_pointer<_Tp>>::type 668 { }; 669 670 /// is_object 671 template
672 struct is_object 673 : public __not_<__or_
, is_reference<_Tp>, 674 is_void<_Tp>>>::type 675 { }; 676 677 template
678 struct is_member_pointer; 679 680 /// is_scalar 681 template
682 struct is_scalar 683 : public __or_
, is_enum<_Tp>, is_pointer<_Tp>, 684 is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type 685 { }; 686 687 /// is_compound 688 template
689 struct is_compound 690 : public __not_
>::type { }; 691 692 /// @cond undocumented 693 template
694 struct __is_member_pointer_helper 695 : public false_type { }; 696 697 template
698 struct __is_member_pointer_helper<_Tp _Cp::*> 699 : public true_type { }; 700 /// @endcond 701 702 /// is_member_pointer 703 template
704 struct is_member_pointer 705 : public __is_member_pointer_helper<__remove_cv_t<_Tp>>::type 706 { }; 707 708 template
709 struct is_same; 710 711 /// @cond undocumented 712 template
713 using __is_one_of = __or_
...>; 714 715 // Check if a type is one of the signed integer types. 716 __extension__ 717 template
718 using __is_signed_integer = __is_one_of<__remove_cv_t<_Tp>, 719 signed char, signed short, signed int, signed long, 720 signed long long 721 #if defined(__GLIBCXX_TYPE_INT_N_0) 722 , signed __GLIBCXX_TYPE_INT_N_0 723 #endif 724 #if defined(__GLIBCXX_TYPE_INT_N_1) 725 , signed __GLIBCXX_TYPE_INT_N_1 726 #endif 727 #if defined(__GLIBCXX_TYPE_INT_N_2) 728 , signed __GLIBCXX_TYPE_INT_N_2 729 #endif 730 #if defined(__GLIBCXX_TYPE_INT_N_3) 731 , signed __GLIBCXX_TYPE_INT_N_3 732 #endif 733 >; 734 735 // Check if a type is one of the unsigned integer types. 736 __extension__ 737 template
738 using __is_unsigned_integer = __is_one_of<__remove_cv_t<_Tp>, 739 unsigned char, unsigned short, unsigned int, unsigned long, 740 unsigned long long 741 #if defined(__GLIBCXX_TYPE_INT_N_0) 742 , unsigned __GLIBCXX_TYPE_INT_N_0 743 #endif 744 #if defined(__GLIBCXX_TYPE_INT_N_1) 745 , unsigned __GLIBCXX_TYPE_INT_N_1 746 #endif 747 #if defined(__GLIBCXX_TYPE_INT_N_2) 748 , unsigned __GLIBCXX_TYPE_INT_N_2 749 #endif 750 #if defined(__GLIBCXX_TYPE_INT_N_3) 751 , unsigned __GLIBCXX_TYPE_INT_N_3 752 #endif 753 >; 754 755 // Check if a type is one of the signed or unsigned integer types. 756 template
757 using __is_standard_integer 758 = __or_<__is_signed_integer<_Tp>, __is_unsigned_integer<_Tp>>; 759 760 // __void_t (std::void_t for C++11) 761 template
using __void_t = void; 762 /// @endcond 763 764 // Type properties. 765 766 /// is_const 767 template
768 struct is_const 769 : public false_type { }; 770 771 template
772 struct is_const<_Tp const> 773 : public true_type { }; 774 775 /// is_volatile 776 template
777 struct is_volatile 778 : public false_type { }; 779 780 template
781 struct is_volatile<_Tp volatile> 782 : public true_type { }; 783 784 /// is_trivial 785 template
786 struct is_trivial 787 : public integral_constant
788 { 789 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 790 "template argument must be a complete class or an unbounded array"); 791 }; 792 793 /// is_trivially_copyable 794 template
795 struct is_trivially_copyable 796 : public integral_constant
797 { 798 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 799 "template argument must be a complete class or an unbounded array"); 800 }; 801 802 /// is_standard_layout 803 template
804 struct is_standard_layout 805 : public integral_constant
806 { 807 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 808 "template argument must be a complete class or an unbounded array"); 809 }; 810 811 /** is_pod 812 * @deprecated Deprecated in C++20. 813 * Use `is_standard_layout && is_trivial` instead. 814 */ 815 // Could use is_standard_layout && is_trivial instead of the builtin. 816 template
817 struct 818 _GLIBCXX20_DEPRECATED_SUGGEST("is_standard_layout && is_trivial") 819 is_pod 820 : public integral_constant
821 { 822 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 823 "template argument must be a complete class or an unbounded array"); 824 }; 825 826 /** is_literal_type 827 * @deprecated Deprecated in C++17, removed in C++20. 828 * The idea of a literal type isn't useful. 829 */ 830 template
831 struct 832 _GLIBCXX17_DEPRECATED 833 is_literal_type 834 : public integral_constant
835 { 836 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 837 "template argument must be a complete class or an unbounded array"); 838 }; 839 840 /// is_empty 841 template
842 struct is_empty 843 : public integral_constant
844 { }; 845 846 /// is_polymorphic 847 template
848 struct is_polymorphic 849 : public integral_constant
850 { }; 851 852 #if __cplusplus >= 201402L 853 #define __cpp_lib_is_final 201402L 854 /// is_final 855 /// @since C++14 856 template
857 struct is_final 858 : public integral_constant
859 { }; 860 #endif 861 862 /// is_abstract 863 template
864 struct is_abstract 865 : public integral_constant
866 { }; 867 868 /// @cond undocumented 869 template
::value> 871 struct __is_signed_helper 872 : public false_type { }; 873 874 template
875 struct __is_signed_helper<_Tp, true> 876 : public integral_constant
877 { }; 878 /// @endcond 879 880 /// is_signed 881 template
882 struct is_signed 883 : public __is_signed_helper<_Tp>::type 884 { }; 885 886 /// is_unsigned 887 template
888 struct is_unsigned 889 : public __and_
, __not_
>>::type 890 { }; 891 892 /// @cond undocumented 893 template
894 _Up 895 __declval(int); 896 897 template
898 _Tp 899 __declval(long); 900 /// @endcond 901 902 template
903 auto declval() noexcept -> decltype(__declval<_Tp>(0)); 904 905 template
906 struct remove_all_extents; 907 908 /// @cond undocumented 909 template
910 struct __is_array_known_bounds 911 : public false_type 912 { }; 913 914 template
915 struct __is_array_known_bounds<_Tp[_Size]> 916 : public true_type 917 { }; 918 919 template
920 struct __is_array_unknown_bounds 921 : public false_type 922 { }; 923 924 template
925 struct __is_array_unknown_bounds<_Tp[]> 926 : public true_type 927 { }; 928 929 // Destructible and constructible type properties. 930 931 // In N3290 is_destructible does not say anything about function 932 // types and abstract types, see LWG 2049. This implementation 933 // describes function types as non-destructible and all complete 934 // object types as destructible, iff the explicit destructor 935 // call expression is wellformed. 936 struct __do_is_destructible_impl 937 { 938 template
().~_Tp())> 939 static true_type __test(int); 940 941 template
942 static false_type __test(...); 943 }; 944 945 template
946 struct __is_destructible_impl 947 : public __do_is_destructible_impl 948 { 949 typedef decltype(__test<_Tp>(0)) type; 950 }; 951 952 template
, 954 __is_array_unknown_bounds<_Tp>, 955 is_function<_Tp>>::value, 956 bool = __or_
, is_scalar<_Tp>>::value> 957 struct __is_destructible_safe; 958 959 template
960 struct __is_destructible_safe<_Tp, false, false> 961 : public __is_destructible_impl
::type>::type 963 { }; 964 965 template
966 struct __is_destructible_safe<_Tp, true, false> 967 : public false_type { }; 968 969 template
970 struct __is_destructible_safe<_Tp, false, true> 971 : public true_type { }; 972 /// @endcond 973 974 /// is_destructible 975 template
976 struct is_destructible 977 : public __is_destructible_safe<_Tp>::type 978 { 979 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 980 "template argument must be a complete class or an unbounded array"); 981 }; 982 983 /// @cond undocumented 984 985 // is_nothrow_destructible requires that is_destructible is 986 // satisfied as well. We realize that by mimicing the 987 // implementation of is_destructible but refer to noexcept(expr) 988 // instead of decltype(expr). 989 struct __do_is_nt_destructible_impl 990 { 991 template
992 static __bool_constant
().~_Tp())> 993 __test(int); 994 995 template
996 static false_type __test(...); 997 }; 998 999 template
1000 struct __is_nt_destructible_impl 1001 : public __do_is_nt_destructible_impl 1002 { 1003 typedef decltype(__test<_Tp>(0)) type; 1004 }; 1005 1006 template
, 1008 __is_array_unknown_bounds<_Tp>, 1009 is_function<_Tp>>::value, 1010 bool = __or_
, is_scalar<_Tp>>::value> 1011 struct __is_nt_destructible_safe; 1012 1013 template
1014 struct __is_nt_destructible_safe<_Tp, false, false> 1015 : public __is_nt_destructible_impl
::type>::type 1017 { }; 1018 1019 template
1020 struct __is_nt_destructible_safe<_Tp, true, false> 1021 : public false_type { }; 1022 1023 template
1024 struct __is_nt_destructible_safe<_Tp, false, true> 1025 : public true_type { }; 1026 /// @endcond 1027 1028 /// is_nothrow_destructible 1029 template
1030 struct is_nothrow_destructible 1031 : public __is_nt_destructible_safe<_Tp>::type 1032 { 1033 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1034 "template argument must be a complete class or an unbounded array"); 1035 }; 1036 1037 /// @cond undocumented 1038 template
1039 using __is_constructible_impl 1040 = __bool_constant<__is_constructible(_Tp, _Args...)>; 1041 /// @endcond 1042 1043 /// is_constructible 1044 template
1045 struct is_constructible 1046 : public __is_constructible_impl<_Tp, _Args...> 1047 { 1048 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1049 "template argument must be a complete class or an unbounded array"); 1050 }; 1051 1052 /// is_default_constructible 1053 template
1054 struct is_default_constructible 1055 : public __is_constructible_impl<_Tp> 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
1063 struct __add_lvalue_reference_helper 1064 { using type = _Tp; }; 1065 1066 template
1067 struct __add_lvalue_reference_helper<_Tp, __void_t<_Tp&>> 1068 { using type = _Tp&; }; 1069 1070 template
1071 using __add_lval_ref_t = typename __add_lvalue_reference_helper<_Tp>::type; 1072 /// @endcond 1073 1074 /// is_copy_constructible 1075 template
1076 struct is_copy_constructible 1077 : public __is_constructible_impl<_Tp, __add_lval_ref_t
> 1078 { 1079 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1080 "template argument must be a complete class or an unbounded array"); 1081 }; 1082 1083 /// @cond undocumented 1084 template
1085 struct __add_rvalue_reference_helper 1086 { using type = _Tp; }; 1087 1088 template
1089 struct __add_rvalue_reference_helper<_Tp, __void_t<_Tp&&>> 1090 { using type = _Tp&&; }; 1091 1092 template
1093 using __add_rval_ref_t = typename __add_rvalue_reference_helper<_Tp>::type; 1094 /// @endcond 1095 1096 /// is_move_constructible 1097 template
1098 struct is_move_constructible 1099 : public __is_constructible_impl<_Tp, __add_rval_ref_t<_Tp>> 1100 { 1101 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1102 "template argument must be a complete class or an unbounded array"); 1103 }; 1104 1105 /// @cond undocumented 1106 template
1107 using __is_nothrow_constructible_impl 1108 = __bool_constant<__is_nothrow_constructible(_Tp, _Args...)>; 1109 /// @endcond 1110 1111 /// is_nothrow_constructible 1112 template
1113 struct is_nothrow_constructible 1114 : public __is_nothrow_constructible_impl<_Tp, _Args...> 1115 { 1116 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1117 "template argument must be a complete class or an unbounded array"); 1118 }; 1119 1120 /// is_nothrow_default_constructible 1121 template
1122 struct is_nothrow_default_constructible 1123 : public __is_nothrow_constructible_impl<_Tp> 1124 { 1125 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1126 "template argument must be a complete class or an unbounded array"); 1127 }; 1128 1129 /// is_nothrow_copy_constructible 1130 template
1131 struct is_nothrow_copy_constructible 1132 : public __is_nothrow_constructible_impl<_Tp, __add_lval_ref_t
> 1133 { 1134 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1135 "template argument must be a complete class or an unbounded array"); 1136 }; 1137 1138 /// is_nothrow_move_constructible 1139 template
1140 struct is_nothrow_move_constructible 1141 : public __is_nothrow_constructible_impl<_Tp, __add_rval_ref_t<_Tp>> 1142 { 1143 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1144 "template argument must be a complete class or an unbounded array"); 1145 }; 1146 1147 /// @cond undocumented 1148 template
1149 using __is_assignable_impl = __bool_constant<__is_assignable(_Tp, _Up)>; 1150 /// @endcond 1151 1152 /// is_assignable 1153 template
1154 struct is_assignable 1155 : public __is_assignable_impl<_Tp, _Up> 1156 { 1157 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1158 "template argument must be a complete class or an unbounded array"); 1159 }; 1160 1161 /// is_copy_assignable 1162 template
1163 struct is_copy_assignable 1164 : public __is_assignable_impl<__add_lval_ref_t<_Tp>, 1165 __add_lval_ref_t
> 1166 { 1167 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1168 "template argument must be a complete class or an unbounded array"); 1169 }; 1170 1171 /// is_move_assignable 1172 template
1173 struct is_move_assignable 1174 : public __is_assignable_impl<__add_lval_ref_t<_Tp>, __add_rval_ref_t<_Tp>> 1175 { 1176 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1177 "template argument must be a complete class or an unbounded array"); 1178 }; 1179 1180 /// @cond undocumented 1181 template
1182 using __is_nothrow_assignable_impl 1183 = __bool_constant<__is_nothrow_assignable(_Tp, _Up)>; 1184 /// @endcond 1185 1186 /// is_nothrow_assignable 1187 template
1188 struct is_nothrow_assignable 1189 : public __is_nothrow_assignable_impl<_Tp, _Up> 1190 { 1191 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1192 "template argument must be a complete class or an unbounded array"); 1193 }; 1194 1195 /// is_nothrow_copy_assignable 1196 template
1197 struct is_nothrow_copy_assignable 1198 : public __is_nothrow_assignable_impl<__add_lval_ref_t<_Tp>, 1199 __add_lval_ref_t
> 1200 { 1201 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1202 "template argument must be a complete class or an unbounded array"); 1203 }; 1204 1205 /// is_nothrow_move_assignable 1206 template
1207 struct is_nothrow_move_assignable 1208 : public __is_nothrow_assignable_impl<__add_lval_ref_t<_Tp>, 1209 __add_rval_ref_t<_Tp>> 1210 { 1211 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1212 "template argument must be a complete class or an unbounded array"); 1213 }; 1214 1215 /// @cond undocumented 1216 template
1217 using __is_trivially_constructible_impl 1218 = __bool_constant<__is_trivially_constructible(_Tp, _Args...)>; 1219 /// @endcond 1220 1221 /// is_trivially_constructible 1222 template
1223 struct is_trivially_constructible 1224 : public __is_trivially_constructible_impl<_Tp, _Args...> 1225 { 1226 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1227 "template argument must be a complete class or an unbounded array"); 1228 }; 1229 1230 /// is_trivially_default_constructible 1231 template
1232 struct is_trivially_default_constructible 1233 : public __is_trivially_constructible_impl<_Tp> 1234 { 1235 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1236 "template argument must be a complete class or an unbounded array"); 1237 }; 1238 1239 struct __do_is_implicitly_default_constructible_impl 1240 { 1241 template
1242 static void __helper(const _Tp&); 1243 1244 template
1245 static true_type __test(const _Tp&, 1246 decltype(__helper
({}))* = 0); 1247 1248 static false_type __test(...); 1249 }; 1250 1251 template
1252 struct __is_implicitly_default_constructible_impl 1253 : public __do_is_implicitly_default_constructible_impl 1254 { 1255 typedef decltype(__test(declval<_Tp>())) type; 1256 }; 1257 1258 template
1259 struct __is_implicitly_default_constructible_safe 1260 : public __is_implicitly_default_constructible_impl<_Tp>::type 1261 { }; 1262 1263 template
1264 struct __is_implicitly_default_constructible 1265 : public __and_<__is_constructible_impl<_Tp>, 1266 __is_implicitly_default_constructible_safe<_Tp>>::type 1267 { }; 1268 1269 /// is_trivially_copy_constructible 1270 template
1271 struct is_trivially_copy_constructible 1272 : public __is_trivially_constructible_impl<_Tp, __add_lval_ref_t
> 1273 { 1274 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1275 "template argument must be a complete class or an unbounded array"); 1276 }; 1277 1278 /// is_trivially_move_constructible 1279 template
1280 struct is_trivially_move_constructible 1281 : public __is_trivially_constructible_impl<_Tp, __add_rval_ref_t<_Tp>> 1282 { 1283 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1284 "template argument must be a complete class or an unbounded array"); 1285 }; 1286 1287 /// @cond undocumented 1288 template
1289 using __is_trivially_assignable_impl 1290 = __bool_constant<__is_trivially_assignable(_Tp, _Up)>; 1291 /// @endcond 1292 1293 /// is_trivially_assignable 1294 template
1295 struct is_trivially_assignable 1296 : public __is_trivially_assignable_impl<_Tp, _Up> 1297 { 1298 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1299 "template argument must be a complete class or an unbounded array"); 1300 }; 1301 1302 /// is_trivially_copy_assignable 1303 template
1304 struct is_trivially_copy_assignable 1305 : public __is_trivially_assignable_impl<__add_lval_ref_t<_Tp>, 1306 __add_lval_ref_t
> 1307 { 1308 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1309 "template argument must be a complete class or an unbounded array"); 1310 }; 1311 1312 /// is_trivially_move_assignable 1313 template
1314 struct is_trivially_move_assignable 1315 : public __is_trivially_assignable_impl<__add_lval_ref_t<_Tp>, 1316 __add_rval_ref_t<_Tp>> 1317 { 1318 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1319 "template argument must be a complete class or an unbounded array"); 1320 }; 1321 1322 /// is_trivially_destructible 1323 template
1324 struct is_trivially_destructible 1325 : public __and_<__is_destructible_safe<_Tp>, 1326 __bool_constant<__has_trivial_destructor(_Tp)>>::type 1327 { 1328 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), 1329 "template argument must be a complete class or an unbounded array"); 1330 }; 1331 1332 1333 /// has_virtual_destructor 1334 template
1335 struct has_virtual_destructor 1336 : public integral_constant