Changeset 6175b78 in mainline
- Timestamp:
- 2018-07-05T21:41:23Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 73e3791
- Parents:
- 9c9ee5d
- git-author:
- Dzejrou <dzejrou@…> (2018-05-12 21:01:29)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/type_traits.hpp
r9c9ee5d r6175b78 564 564 565 565 template<class T> 566 struct is_standard_layout; 566 struct is_standard_layout: aux::value_is<bool, __is_standard_layout(T)> 567 { /* DUMMY BODY */ }; 567 568 568 569 template<class T> … … 669 670 670 671 template<class T> 671 struct is_default_constructible; 672 673 template<class T> 674 struct is_copy_constructible; 675 676 template<class T> 677 struct is_move_constructible; 672 struct is_default_constructible 673 : is_constructible<T> 674 { /* DUMMY BODY */ }; 675 676 template<class T> 677 struct is_copy_constructible 678 : is_constructible<T, add_lvalue_reference<const T>> 679 { /* DUMMY BODY */ }; 680 681 template<class T> 682 struct is_move_constructible 683 : is_constructible<T, add_rvalue_reference<T>> 684 { /* DUMMY BODY */ }; 685 686 template<class T, class U, class = void> 687 struct is_assignable: false_type 688 { /* DUMMY BODY */ }; 678 689 679 690 template<class T, class U> 680 struct is_assignable; 681 682 template<class T> 683 struct is_copy_assignable; 684 685 template<class T> 686 struct is_move_assignable; 687 688 template<class T> 689 struct is_destructible; 691 struct is_assignable<T, U, void_t<decltype(declval<T>() = declval<U>())>> 692 : true_type 693 { /* DUMMY BODY */ }; 694 695 template<class T> 696 struct is_copy_assignable 697 : is_assignable<add_lvalue_reference_t<T>, add_lvalue_reference_t<const T>> 698 { /* DUMMY BODY */ }; 699 700 template<class T> 701 struct is_move_assignable 702 : is_assignable<add_lvalue_reference_t<T>, add_rvalue_reference_t<T>> 703 { /* DUMMY BODY */ }; 704 705 template<class, class = void> 706 struct is_destructible: false_type 707 { /* DUMMY BODY */ }; 708 709 template<class T> 710 struct is_destructible<T, void_t<decltype(declval<T&>().~T())>> 711 : true_type 712 { /* DUMMY BODY */ }; 690 713 691 714 template<class T, class... Args> … … 697 720 698 721 template<class T> 699 struct is_trivially_default_constructible; 722 struct is_trivially_default_constructible 723 : is_trivially_constructible<T> 724 { /* DUMMY BODY */ }; 700 725 701 726 template<class T> … … 707 732 708 733 template<class T> 709 struct is_trivially_move_constructible; 734 struct is_trivially_move_constructible 735 : is_trivially_constructible<T, add_rvalue_reference_t<T>> 736 { /* DUMMY BODY */ }; 710 737 711 738 template<class T, class U> 712 struct is_trivially_assignable: aux::value_is<bool, __has_trivial_assign(T) >739 struct is_trivially_assignable: aux::value_is<bool, __has_trivial_assign(T) && is_assignable<T, U>::value> 713 740 { /* DUMMY BODY */ }; 714 741 … … 717 744 718 745 template<class T> 719 struct is_trivially_copy_assignable; 720 721 template<class T> 722 struct is_trivially_move_assignable; 746 struct is_trivially_copy_assignable 747 : is_trivially_assignable<add_lvalue_reference_t<T>, add_lvalue_reference_t<const T>> 748 { /* DUMMY BODY */ }; 749 750 template<class T> 751 struct is_trivially_move_assignable 752 : is_trivially_assignable<add_lvalue_reference_t<T>, add_rvalue_reference_t<T>> 753 { /* DUMMY BODY */ }; 723 754 724 755 template<class T> … … 737 768 738 769 template<class T> 739 struct is_nothrow_default_constructible; 770 struct is_nothrow_default_constructible 771 : is_nothrow_constructible<T> 772 { /* DUMMY BODY */ }; 740 773 741 774 template<class T> … … 747 780 748 781 template<class T> 749 struct is_nothrow_move_constructible; 782 struct is_nothrow_move_constructible 783 : is_nothrow_constructible<add_lvalue_reference_t<T>, add_rvalue_reference_t<T>> 784 { /* DUMMY BODY */ }; 750 785 751 786 template<class T, class U> … … 757 792 758 793 template<class T> 759 struct is_nothrow_copy_assignable; 760 761 template<class T> 762 struct is_nothrow_move_assignable; 763 764 template<class T> 765 struct is_nothrow_destructible; 794 struct is_nothrow_copy_assignable 795 : is_nothrow_assignable<add_lvalue_reference_t<T>, add_lvalue_reference_t<const T>> 796 { /* DUMMY BODY */ }; 797 798 template<class T> 799 struct is_nothrow_move_assignable 800 : is_nothrow_assignable<add_lvalue_reference_t<T>, add_rvalue_reference_t<T>> 801 { /* DUMMY BODY */ }; 802 803 template<class, class = void> 804 struct is_nothrow_destructible: false_type 805 { /* DUMMY BODY */ }; 806 807 template<class T> 808 struct is_nothrow_destructible<T, void_t<decltype(declval<T&>().~T())>> 809 : aux::value_is<bool, noexcept(declval<T&>().~T())> 810 { /* DUMMY BODY */ }; 766 811 767 812 template<class T> … … 777 822 778 823 template<class T> 779 struct alignment_of; 824 struct alignment_of: aux::value_is<std::size_t, alignof(T)> 825 { /* DUMMY BODY */ }; 780 826 781 827 template<class> … … 794 840 inline constexpr size_t rank_v = rank<T>::value; 795 841 796 template<class T, unsigned I = 0> 797 struct extent; 842 template<class T, unsigned I = 0U> 843 struct extent: aux::value_is<size_t, 0U> 844 { /* DUMMY BODY */ }; 845 846 template<class T> 847 struct extent<T[], 0U>: aux::value_is<size_t, 0U> 848 { /* DUMMY BODY */ }; 849 850 template<class T, unsigned I> 851 struct extent<T[], I>: extent<T, I - 1> 852 { /* DUMMY BODY */ }; 853 854 template<class T, size_t N> 855 struct extent<T[N], 0U>: aux::value_is<size_t, 0U> 856 { /* DUMMY BODY */ }; 857 858 template<class T, unsigned I, size_t N> 859 struct extent<T[N], I>: extent<T, I - 1> 860 { /* DUMMY BODY */ }; 798 861 799 862 /** … … 926 989 927 990 template<class T> 928 struct remove_all_extents; 991 struct remove_all_extents: aux::type_is<T> 992 { /* DUMMY BODY */ }; 993 994 template<class T> 995 struct remove_all_extents<T[]>: remove_all_extents<T> 996 { /* DUMMY BODY */ }; 997 998 template<class T, size_t N> 999 struct remove_all_extents<T[N]>: remove_all_extents<T> 1000 { /* DUMMY BODY */ }; 929 1001 930 1002 template<class T> … … 958 1030 { /* DUMMY BODY */ }; 959 1031 960 template<class T> 961 struct add_pointer; 1032 namespace aux 1033 { 1034 template<class T> 1035 struct add_pointer_to_function: type_is<T> 1036 { /* DUMMY BODY */ }; 1037 1038 template<class T, class... Args> 1039 struct add_pointer_to_function<T(Args...)> 1040 : type_is<T(*)(Args...)> 1041 { /* DUMMY BODY */ }; 1042 1043 template<class T, bool = false> 1044 struct add_pointer_cond: aux::type_is<remove_reference_t<T>*> 1045 { /* DUMMY BODY */ }; 1046 1047 template<class T> 1048 struct add_pointer_cond<T, true> 1049 : aux::add_pointer_to_function<T> 1050 { /* DUMMY BODY */ }; 1051 } 1052 1053 template<class T> 1054 struct add_pointer: aux::add_pointer_cond<T, is_function_v<T>> 1055 { /* DUMMY BODY */ }; 962 1056 963 1057 template<class T> … … 970 1064 * 20.10.7.6, other transformations: 971 1065 */ 1066 1067 namespace aux 1068 { 1069 template<size_t Len, size_t Align> 1070 struct aligned_t 1071 { 1072 alignas(Align) uint8_t storage[Len]; 1073 }; 1074 1075 template<class T> 1076 constexpr T max_of_cont(T cont) 1077 { 1078 if (cont.size() == 0U) 1079 return T{}; 1080 1081 auto it = cont.begin(); 1082 auto res = *it; 1083 1084 while (++it != cont.end()) 1085 { 1086 if (*it > res) 1087 res = *it; 1088 } 1089 1090 return res; 1091 } 1092 } 972 1093 973 1094 // TODO: consult standard on the default value of align 974 1095 template<std::size_t Len, std::size_t Align = 0> 975 struct aligned_storage; 1096 struct aligned_storage: aux::type_is<aux::aligned_t<Len, Align>> 1097 { /* DUMMY BODY */ }; 976 1098 977 1099 template<std::size_t Len, class... Types> 978 struct aligned_union; 1100 struct aligned_union: aux::type_is< 1101 aux::aligned_t< 1102 aux::max_of_cont({Len, alignof(Types)...}), 1103 aux::max_of_cont({alignof(Types)...}) 1104 > 1105 > 1106 { /* DUMMY BODY */ }; 979 1107 980 1108 // TODO: this is very basic implementation for chrono, fix! 981 template<class T> 982 struct decay: aux::type_is<remove_cv_t<remove_reference_t<T>>> 983 { /* DUMMY BODY */ }; 1109 /* template<class T> */ 1110 /* struct decay: aux::type_is<remove_cv_t<remove_reference_t<T>>> */ 1111 /* { /1* DUMMY BODY *1/ }; */ 1112 1113 template<bool, class, class> 1114 struct conditional; 1115 1116 template<class T> 1117 struct decay: aux::type_is< 1118 typename conditional< 1119 is_array_v<remove_reference_t<T>>, 1120 remove_extent_t<remove_reference_t<T>>*, 1121 typename conditional< 1122 is_function_v<remove_reference_t<T>>, 1123 add_pointer_t<remove_reference_t<T>>, 1124 remove_cv_t<remove_reference_t<T>> 1125 >::type 1126 >::type 1127 > 1128 { /* DUMMY BODY */ }; 984 1129 985 1130 template<class T>
Note:
See TracChangeset
for help on using the changeset viewer.