Changeset 9400dbe in mainline
- Timestamp:
- 2018-07-05T21:41:18Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3f5b7126
- Parents:
- d13b67a
- git-author:
- Jaroslav Jindrak <dzejrou@…> (2017-11-11 00:13:44)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:18)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/type_traits.hpp
rd13b67a r9400dbe 62 62 using false_type = integral_constant<bool, false>; 63 63 64 /**65 * 20.10.4.1, primary type categories:66 */67 68 64 template<class> 69 65 struct remove_cv; … … 72 68 using remove_cv_t = typename remove_cv<T>::type; 73 69 74 template<class> 75 struct __is_void: false_type 76 { /* DUMMY BODY */ }; 77 78 template<> 79 struct __is_void<void>: true_type 80 { /* DUMMY BODY */ }; 81 82 template<class T> 83 struct is_void: __is_void<remove_cv_t<T>> 84 { /* DUMMY BODY */ }; 85 86 template<class> 87 struct __is_null_pointer: false_type 88 { /* DUMMY BODY */ }; 89 90 template<> 91 struct __is_null_pointer<nullptr_t>: true_type 92 { /* DUMMY BODY */ }; 93 94 template<class T> 95 struct is_null_pointer: __is_null_pointer<remove_cv_t<T>> 96 { /* DUMMY BODY */ }; 97 98 template<class T> 99 struct __is_integral: false_type 100 { /* DUMMY BODY */ }; 101 102 template<> 103 struct __is_integral<bool>: true_type 104 { /* DUMMY BODY */ }; 105 106 template<> 107 struct __is_integral<char>: true_type 108 { /* DUMMY BODY */ }; 109 110 template<> 111 struct __is_integral<signed char>: true_type 112 { /* DUMMY BODY */ }; 113 114 template<> 115 struct __is_integral<unsigned char>: true_type 116 { /* DUMMY BODY */ }; 117 118 /* TODO: Problem - wchar_t is typedef'd to int here. 119 template<> 120 struct __is_integral<wchar_t>; 121 */ 122 123 template<> 124 struct __is_integral<long>: true_type 125 { /* DUMMY BODY */ }; 126 127 template<> 128 struct __is_integral<unsigned long>: true_type 129 { /* DUMMY BODY */ }; 130 131 template<> 132 struct __is_integral<int>: true_type 133 { /* DUMMY BODY */ }; 134 135 template<> 136 struct __is_integral<unsigned int>: true_type 137 { /* DUMMY BODY */ }; 138 139 template<> 140 struct __is_integral<short>: true_type 141 { /* DUMMY BODY */ }; 142 143 template<> 144 struct __is_integral<unsigned short>: true_type 145 { /* DUMMY BODY */ }; 146 147 template<> 148 struct __is_integral<long long>: true_type 149 { /* DUMMY BODY */ }; 150 151 template<> 152 struct __is_integral<unsigned long long>: true_type 153 { /* DUMMY BODY */ }; 154 155 template<class T> // TODO: use remove_cv when implemented 156 struct is_integral: __is_integral<T> 157 { /* DUMMY BODY */ }; 158 159 template<class> 160 struct __is_floating_point: false_type 161 { /* DUMMY BODY */ }; 162 163 template<> 164 struct __is_floating_point<float>: true_type 165 { /* DUMMY BODY */ }; 166 167 template<> 168 struct __is_floating_point<double>: true_type 169 { /* DUMMY BODY */ }; 170 171 template<> 172 struct __is_floating_point<long double>: true_type 173 { /* DUMMY BODY */ }; 174 175 template<class T> 176 struct is_floating_point: __is_floating_point<remove_cv_t<T>> 70 namespace aux 71 { 72 template<class T, class U> 73 struct is_same: false_type 74 { /* DUMMY BODY */ }; 75 76 template<class T> 77 struct is_same<T, T>: true_type 78 { /* DUMMY BODY */ }; 79 80 template<class T, class U> 81 struct is_one_of: is_same<T, Y> 82 { /* DUMMY BODY */ }; 83 84 template<class T, class, class... Ts> 85 struct is_one_of: is_one_of<T, Ts...> 86 { /* DUMMY BODY */ }; 87 88 template<class T, class U, class...> 89 struct is_one_of: true_type 90 { /* DUMMY BODY */ }; 91 } 92 93 /** 94 * 20.10.4.1, primary type categories: 95 */ 96 97 template<class T> 98 struct is_void: is_same<remove_cv_t<T>, void> 99 { /* DUMMY BODY */ }; 100 101 template<class T> 102 struct is_null_pointer: is_same<remove_cv_t<T>, nullptr_t> 103 { /* DUMMY BODY */ }; 104 105 template<class T> 106 struct is_integral: aux::is_one_of<remove_cv_t<T>, 107 bool, char, unsigned char, signed char, 108 long, unsigned long, int, unsigned int, short, 109 unsigned short, long long, unsigned long long> 110 { /* DUMMY BODY */ }; 111 112 template<class T> 113 struct is_floating_point 114 : is_one_of<remove_cv_t<T>, float, double, long double> 177 115 { /* DUMMY BODY */ }; 178 116 … … 185 123 { /* DUMMY BODY */ }; 186 124 187 template<class> 188 struct __is_pointer: false_type 189 { /* DUMMY BODY */ }; 190 191 template<class T> 192 struct __is_pointer<T*>: true_type 193 { /* DUMMY BODY */ }; 194 195 template<class T> 196 struct is_pointer: __is_pointer<remove_cv_t<T>> 125 namespace aux 126 { 127 template<class> 128 struct is_pointer: false_type 129 { /* DUMMY BODY */ }; 130 131 template<class T> 132 struct is_pointer<T*>: true_type 133 { /* DUMMY BODY */ }; 134 } 135 136 template<class T> 137 struct is_pointer: aux::is_pointer<remove_cv_t<T>> 197 138 { /* DUMMY BODY */ }; 198 139 … … 228 169 struct is_function; 229 170 230 template<class T> 231 struct __is_member_function_pointer: false_type 232 { /* DUMMY BODY */ }; 233 234 template<class T, class U> 235 struct __is_member_function_pointer<T U::*>: is_function<T> 236 { /* DUMMY BODY */ }; 237 238 template<class T> 239 struct is_member_function_pointer: __is_member_function_pointer<remove_cv_t<T>> 240 { /* DUMMY BODY */ }; 241 242 template<class T> 243 struct is_enum; // TODO: No idea how to implement. 244 245 template<class T> 246 struct is_union; // TODO: No idea how to implement. 247 248 template<class T> 249 struct is_class; // TODO: No idea how to implement. 171 namespace aux 172 { 173 template<class T> 174 struct is_member_function_pointer: false_type 175 { /* DUMMY BODY */ }; 176 177 template<class T, class U> 178 struct is_member_function_pointer<T U::*>: is_function<T> 179 { /* DUMMY BODY */ }; 180 } 181 182 template<class T> 183 struct is_member_function_pointer: aux::is_member_function_pointer<remove_cv_t<T>> 184 { /* DUMMY BODY */ }; 185 186 template<class T> 187 struct is_enum: aux::value_is<__is_enum(T)> 188 { /* DUMMY BODY */ }; 189 190 template<class T> 191 struct is_union: aux::value_is<__is_union(T)> 192 { /* DUMMY BODY */ }; 193 194 template<class T> 195 struct is_class: aux::value_is<__is_class(T)> 196 { /* DUMMY BODY */ }; 250 197 251 198 /** … … 457 404 458 405 template<class T> 459 struct is_arithmetic; 406 struct is_arithmetic: aux::value_is< 407 bool, 408 is_integral<T>::value || is_floating_point<T>::value> 409 { /* DUMMY BODY */ }; 460 410 461 411 template<class T> … … 471 421 struct is_compound; 472 422 473 template<class T> 474 struct __is_member_pointer: false_type 475 { /* DUMMY BODY */ }; 476 477 template<class T, class U> 478 struct __is_member_pointer<T U::*>: true_type 479 { /* DUMMY BODY */ }; 480 481 template<class T> 482 struct is_member_pointer: __is_member_pointer<remove_cv_t<T>> 423 namespace aux 424 { 425 template<class T> 426 struct is_member_pointer: false_type 427 { /* DUMMY BODY */ }; 428 429 template<class T, class U> 430 struct is_member_pointer<T U::*>: true_type 431 { /* DUMMY BODY */ }; 432 } 433 434 template<class T> 435 struct is_member_pointer: aux::is_member_pointer<remove_cv_t<T>> 483 436 { /* DUMMY BODY */ }; 484 437 … … 488 441 489 442 template<class T> 490 struct is_const; 491 492 template<class T> 493 struct is_volatile; 494 495 template<class T> 496 struct is_trivial; 497 498 template<class T> 499 struct is_trivially_copyable; 443 struct is_const: false_type 444 { /* DUMMY BODY */}; 445 446 template<class T> 447 struct is_const<T const>: true_type 448 { /* DUMMY BODY */}; 449 450 template<class T> 451 struct is_volatile: false_type 452 { /* DUMMY BODY */}; 453 454 template<class T> 455 struct is_volatile<T volatile>: true_type 456 { /* DUMMY BODY */ }; 457 458 template<class T> 459 struct is_trivial: aux::value_is< 460 bool, 461 is_trivially_copyable<T>::value && 462 is_trivially_default_constructible<T>::value> 463 { /* DUMMY BODY */ }; 464 465 template<class T> 466 struct is_trivially_copyable: aux::value_is<bool, __has_trivial_copy(T)> 467 { /* DUMMY BODY */ }; 500 468 501 469 template<class T> … … 503 471 504 472 template<class T> 505 struct is_pod; 506 507 template<class T> 508 struct is_literal_type; 509 510 template<class T> 511 struct is_empty; 512 513 template<class T> 514 struct is_polymorphic; 515 516 template<class T> 517 struct is_abstract; 518 519 template<class T> 520 struct is_final; 521 522 template<class T> 523 struct is_signed; 524 525 template<class T> 526 struct is_unsidned; 473 struct is_pod: aux::value_is<bool, __is_pod(T)> 474 { /* DUMMY BODY */ }; 475 476 template<class T> 477 struct is_literal_type: aux::value_is<bool, __is_literal_type(T)> 478 { /* DUMMY BODY */ }; 479 480 template<class T> 481 struct is_empty: aux::value_is<bool, __is_empty(T)> 482 { /* DUMMY BODY */ }; 483 484 template<class T> 485 struct is_polymorphic: aux::value_is<bool, __is_polymorphic(T)> 486 { /* DUMMY BODY */ }; 487 488 template<class T> 489 struct is_abstract: aux::value_is<bool, __is_abstract(T)> 490 { /* DUMMY BODY */ }; 491 492 template<class T> 493 struct is_final: aux::value_is<bool, __is_final(T)> 494 { /* DUMMY BODY */ }; 495 496 namespace aux 497 { 498 /** 499 * Note: We cannot simply use !is_signed to define 500 * is_unsigned because non-arithmetic types 501 * are neither signer nor unsigned. 502 */ 503 template<class T, bool = is_arithmetic<T>::value> 504 struct is_signed: value_is<bool, T(-1) < T(0)> 505 { /* DUMMY BODY */ }; 506 507 template<class T> 508 struct is_signed<T, false>: false_type 509 { /* DUMMY BODY */ }; 510 511 template<class T, bool = is_arithmetic<T>::value> 512 struct is_unsigned: value_is<bool, T(0) < T(-1)> 513 { /* DUMMY BODY */ }; 514 515 template<class T> 516 struct is_unsigned<T, false>: false_type 517 { /* DUMMY BODY */ }; 518 } 519 520 template<class T> 521 struct is_signed: aux::is_signed<T> 522 { /* DUMMY BODY */ }; 523 524 template<class T> 525 struct is_unsigned: aux::is_unsigned<T> 526 { /* DUMMY BODY */ }; 527 527 528 528 template<class T, class... Args> … … 551 551 552 552 template<class T, class... Args> 553 struct is_trivially_constructible; 553 struct is_trivially_constructible: aux::value_is<bool, __has_trivial_constructor(T)> 554 { /* DUMMY BODY */ }; 554 555 555 556 template<class T> … … 557 558 558 559 template<class T> 559 struct is_trivially_copy_constructible; 560 struct is_trivially_copy_constructible: aux::value_is<bool, __has_trivial_copy(T)> 561 { /* DUMMY BODY */ }; 560 562 561 563 template<class T> … … 563 565 564 566 template<class T, class U> 565 struct is_trivially_assignable; 567 struct is_trivially_assignable: aux::value_is<bool, __has_trivial_assign(T)> 568 { /* DUMMY BODY */ }; 566 569 567 570 template<class T> … … 572 575 573 576 template<class T> 574 struct is_trivially_destructible; 577 struct is_trivially_destructible: aux::value_is<bool, __has_trivial_destructor(T)> 578 { /* DUMMY BODY */ }; 575 579 576 580 template<class T, class... Args> 577 struct is_nothrow_constructible; 581 struct is_nothrow_constructible: aux::value_is<bool, __has_nothrow_constructor(T)> 582 { /* DUMMY BODY */ }; 578 583 579 584 template<class T> … … 581 586 582 587 template<class T> 583 struct is_nothrow_copy_constructible; 588 struct is_nothrow_copy_constructible: aux::value_is<bool, __has_nothrow_copy(T)> 589 { /* DUMMY BODY */ }; 584 590 585 591 template<class T> … … 587 593 588 594 template<class T, class U> 589 struct is_nothrow_assignable; 595 struct is_nothrow_assignable: aux::value_is<bool, __has_nothrow_assign(T)> 596 { /* DUMMY BODY */ }; 590 597 591 598 template<class T> … … 599 606 600 607 template<class T> 601 struct has_virtual_destructor; 608 struct has_virtual_destructor: aux::value_is<bool, __has_nothrow_destructor(T)> 609 { /* DUMMY BODY */ }; 602 610 603 611 /** … … 628 636 629 637 template<class T, class U> 630 struct is_same: false_type 631 { /* DUMMY BODY */ }; 632 633 template<class T> 634 struct is_same<T, T>: true_type 638 struct is_same: aux::is_same<T, U> 635 639 { /* DUMMY BODY */ }; 636 640 … … 780 784 781 785 template<bool, class T = void> 782 struct enable_if; 786 struct enable_if 787 { /* DUMMY BODY */ } 788 789 template<class T> 790 struct enable_if<true, T>: aux::type_is<T> 791 { /* DUMMY BODY */ } 783 792 784 793 template<bool, class T, class F> 785 struct conditional; 794 struct conditional: aux::type_is<F> 795 { /* DUMMY BODY */ }; 796 797 template<class T, class F> 798 struct conditional<true, T, F>: aux::type_is<T> 799 { /* DUMMY BODY */ }; 786 800 787 801 template<class... T>
Note:
See TracChangeset
for help on using the changeset viewer.