type_traits (9070B)
1 // -*- c++ -*- 2 #pragma once 3 4 // only one overload of forward is noexcept 5 // what the fuck are you doing retards 6 // you should go back to your designated shitting streets in india and never 7 // touch a computer again 8 // but none of them is constexpr 9 #pragma push_macro("forward") 10 #define forward(x) \ 11 forward_dummy(x); \ 12 template <typename _Ty> \ 13 inline constexpr _Ty&& forward(x) _Pragma("pop_macro(\"forward\")") 14 #pragma push_macro("forward") 15 #define forward(x) \ 16 forward_dummy(x); \ 17 template <typename _Ty> \ 18 inline constexpr _Ty&& forward(x) noexcept _Pragma("pop_macro(\"forward\")") 19 20 #pragma push_macro("move") 21 #define move(x) \ 22 move_dummy(x); \ 23 template <typename _Ty> \ 24 constexpr typename remove_reference<_Ty>::type&& move(x) \ 25 _Pragma("pop_macro(\"move\")") 26 27 #include_next <type_traits> 28 29 namespace std 30 { 31 32 #define _IS_MEMFUNPTR(CALL_OPT, X1, CV_OPT) \ 33 template<class Ret, class Arg0, class... Types> \ 34 struct _Is_memfunptr<Ret (CALL_OPT Arg0::*)(Types...) CV_OPT noexcept> \ 35 : true_type {}; 36 _MEMBER_CALL_CV(_IS_MEMFUNPTR, ) 37 #undef _IS_MEMFUNPTR 38 39 #define _IS_MEMFUNPTR_ELLIPSIS(CV_OPT) \ 40 template<class Ret, class Arg0, class... Types> \ 41 struct _Is_memfunptr<Ret (Arg0::*)(Types..., ...) CV_OPT noexcept> \ 42 : true_type {}; 43 _CLASS_DEFINE_CV(_IS_MEMFUNPTR_ELLIPSIS) 44 #undef _IS_MEMFUNPTR_ELLIPSIS 45 46 template <typename... T> 47 using void_t = void; 48 49 50 template <bool X> 51 using bool_constant = integral_constant<bool, X>; 52 53 template <typename T> 54 struct is_null_pointer : is_same<nullptr_t, remove_cv_t<T>> {}; 55 56 template <typename T> 57 struct is_final : bool_constant<__is_final(T)> {}; 58 59 60 template <typename T, typename U, typename = void> 61 struct is_swappable_with : false_type {}; 62 63 template <typename T, typename U> 64 struct is_swappable_with<T, U, void_t< 65 decltype(swap(std::declval<T>(), std::declval<U>())), 66 decltype(swap(std::declval<U>(), std::declval<T>()))>> 67 : true_type {}; 68 69 template <typename T> 70 struct is_swappable : is_swappable_with<T&, T&> {}; 71 72 template <typename T, typename U> 73 inline constexpr bool is_swappable_with_v = is_swappable_with<T, U>::value; 74 template <typename T> 75 inline constexpr bool is_swappable_v = is_swappable<T>::value; 76 77 template <typename T, typename U, bool = is_swappable_with_v<T, U>> 78 struct is_nothrow_swappable_with : false_type {}; 79 80 template <typename T, typename U> 81 struct is_nothrow_swappable_with<T, U, true> : bool_constant< 82 noexcept(swap(std::declval<T>(), std::declval<U>())) && 83 noexcept(swap(std::declval<U>(), std::declval<T>()))> {}; 84 85 template <typename T> 86 struct is_nothrow_swappable : is_nothrow_swappable_with<T&, T&> {}; 87 88 template <typename T, typename U> 89 inline constexpr bool is_nothrow_swappable_with_v = 90 is_nothrow_swappable_with<T, U>::value; 91 template <typename T> 92 inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<T>::value; 93 94 // copy-paste from 95 // http://en.cppreference.com/w/cpp/experimental/type_trait_variable_templates 96 template <class T> constexpr bool is_void_v = is_void<T>::value; 97 template <class T> constexpr bool is_null_pointer_v = is_null_pointer<T>::value; 98 template <class T> constexpr bool is_integral_v = is_integral<T>::value; 99 template <class T> constexpr bool is_floating_point_v = is_floating_point<T>::value; 100 template <class T> constexpr bool is_array_v = is_array<T>::value; 101 template <class T> constexpr bool is_pointer_v = is_pointer<T>::value; 102 template <class T> constexpr bool is_lvalue_reference_v = is_lvalue_reference<T>::value; 103 template <class T> constexpr bool is_rvalue_reference_v = is_rvalue_reference<T>::value; 104 template <class T> constexpr bool is_member_object_pointer_v = is_member_object_pointer<T>::value; 105 template <class T> constexpr bool is_member_function_pointer_v = is_member_function_pointer<T>::value; 106 template <class T> constexpr bool is_enum_v = is_enum<T>::value; 107 template <class T> constexpr bool is_union_v = is_union<T>::value; 108 template <class T> constexpr bool is_class_v = is_class<T>::value; 109 template <class T> constexpr bool is_function_v = is_function<T>::value; 110 111 template <class T> constexpr bool is_reference_v = is_reference<T>::value; 112 template <class T> constexpr bool is_arithmetic_v = is_arithmetic<T>::value; 113 template <class T> constexpr bool is_fundamental_v = is_fundamental<T>::value; 114 template <class T> constexpr bool is_object_v = is_object<T>::value; 115 template <class T> constexpr bool is_scalar_v = is_scalar<T>::value; 116 template <class T> constexpr bool is_compound_v = is_compound<T>::value; 117 template <class T> constexpr bool is_member_pointer_v = is_member_pointer<T>::value; 118 119 template <class T> constexpr bool is_const_v = is_const<T>::value; 120 template <class T> constexpr bool is_volatile_v = is_volatile<T>::value; 121 template <class T> constexpr bool is_trivial_v = is_trivial<T>::value; 122 template <class T> constexpr bool is_trivially_copyable_v = is_trivially_copyable<T>::value; 123 template <class T> constexpr bool is_standard_layout_v = is_standard_layout<T>::value; 124 template <class T> constexpr bool is_pod_v = is_pod<T>::value; 125 template <class T> constexpr bool is_literal_type_v = is_literal_type<T>::value; 126 template <class T> constexpr bool is_empty_v = is_empty<T>::value; 127 template <class T> constexpr bool is_polymorphic_v = is_polymorphic<T>::value; 128 template <class T> constexpr bool is_abstract_v = is_abstract<T>::value; 129 template <class T> constexpr bool is_final_v = is_final<T>::value; 130 template <class T> constexpr bool is_signed_v = is_signed<T>::value; 131 template <class T> constexpr bool is_unsigned_v = is_unsigned<T>::value; 132 133 template <class T, class... Args> constexpr bool is_constructible_v = is_constructible<T, Args...>::value; 134 template <class T, class... Args> constexpr bool is_trivially_constructible_v = is_trivially_constructible<T, Args...>::value; 135 template <class T, class... Args> constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<T, Args...>::value; 136 template <class T> constexpr bool is_default_constructible_v = is_default_constructible<T>::value; 137 template <class T> constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<T>::value; 138 template <class T> constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<T>::value; 139 template <class T> constexpr bool is_copy_constructible_v = is_copy_constructible<T>::value; 140 template <class T> constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<T>::value; 141 template <class T> constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<T>::value; 142 template <class T> constexpr bool is_move_constructible_v = is_move_constructible<T>::value; 143 template <class T> constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<T>::value; 144 template <class T> constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<T>::value; 145 template <class T, class U> constexpr bool is_assignable_v = is_assignable<T, U>::value; 146 template <class T, class U> constexpr bool is_trivially_assignable_v = is_trivially_assignable<T, U>::value; 147 template <class T, class U> constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<T, U>::value; 148 template <class T> constexpr bool is_copy_assignable_v = is_copy_assignable<T>::value; 149 template <class T> constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<T>::value; 150 template <class T> constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<T>::value; 151 template <class T> constexpr bool is_move_assignable_v = is_move_assignable<T>::value; 152 template <class T> constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<T>::value; 153 template <class T> constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<T>::value; 154 template <class T> constexpr bool is_destructible_v = is_destructible<T>::value; 155 template <class T> constexpr bool is_trivially_destructible_v = is_trivially_destructible<T>::value; 156 template <class T> constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<T>::value; 157 template <class T> constexpr bool has_virtual_destructor_v = has_virtual_destructor<T>::value; 158 159 template <class T> constexpr size_t alignment_of_v = alignment_of<T>::value; 160 template <class T> constexpr size_t rank_v = rank<T>::value; 161 template <class T, unsigned I = 0> constexpr size_t extent_v = extent<T, I>::value; 162 163 template <class T, class U> constexpr bool is_same_v = is_same<T, U>::value; 164 template <class Base, class Derived> constexpr bool is_base_of_v = is_base_of<Base, Derived>::value; 165 template <class From, class To> constexpr bool is_convertible_v = is_convertible<From, To>::value; 166 167 }