29 #ifndef _GLIBCXX_TYPE_TRAITS
30 #define _GLIBCXX_TYPE_TRAITS 1
32 #pragma GCC system_header
34 #if __cplusplus < 201103L
40 namespace std _GLIBCXX_VISIBILITY(default)
42 _GLIBCXX_BEGIN_NAMESPACE_VERSION
56 template<
typename _Tp, _Tp __v>
59 static constexpr _Tp value = __v;
60 typedef _Tp value_type;
62 constexpr
operator value_type() {
return value; }
65 template<
typename _Tp, _Tp __v>
76 template<
bool,
typename,
typename>
87 template<
typename _B1>
92 template<
typename _B1,
typename _B2>
93 struct __or_<_B1, _B2>
94 :
public conditional<_B1::value, _B1, _B2>::type
97 template<
typename _B1,
typename _B2,
typename _B3,
typename... _Bn>
98 struct __or_<_B1, _B2, _B3, _Bn...>
99 :
public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type
102 template<
typename...>
110 template<
typename _B1>
115 template<
typename _B1,
typename _B2>
116 struct __and_<_B1, _B2>
117 :
public conditional<_B1::value, _B2, _B1>::type
120 template<
typename _B1,
typename _B2,
typename _B3,
typename... _Bn>
121 struct __and_<_B1, _B2, _B3, _Bn...>
122 :
public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type
125 template<
typename _Pp>
127 :
public integral_constant<bool, !_Pp::value>
130 struct __sfinae_types
133 typedef struct {
char __arr[2]; } __two;
141 template<
typename _Tp>
142 struct __success_type
143 {
typedef _Tp type; };
145 struct __failure_type
154 struct __is_void_helper
158 struct __is_void_helper<void>
162 template<
typename _Tp>
165 remove_cv<_Tp>::type>::value)>
169 struct __is_integral_helper
173 struct __is_integral_helper<bool>
177 struct __is_integral_helper<char>
181 struct __is_integral_helper<signed char>
185 struct __is_integral_helper<unsigned char>
188 #ifdef _GLIBCXX_USE_WCHAR_T
190 struct __is_integral_helper<wchar_t>
195 struct __is_integral_helper<char16_t>
199 struct __is_integral_helper<char32_t>
203 struct __is_integral_helper<short>
207 struct __is_integral_helper<unsigned short>
211 struct __is_integral_helper<int>
215 struct __is_integral_helper<unsigned int>
219 struct __is_integral_helper<long>
223 struct __is_integral_helper<unsigned long>
227 struct __is_integral_helper<long long>
231 struct __is_integral_helper<unsigned long long>
234 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
236 struct __is_integral_helper<__int128>
240 struct __is_integral_helper<unsigned __int128>
245 template<
typename _Tp>
248 remove_cv<_Tp>::type>::value)>
252 struct __is_floating_point_helper
256 struct __is_floating_point_helper<float>
260 struct __is_floating_point_helper<double>
264 struct __is_floating_point_helper<long double>
267 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
269 struct __is_floating_point_helper<__float128>
274 template<
typename _Tp>
277 remove_cv<_Tp>::type>::value)>
285 template<
typename _Tp, std::
size_t _Size>
289 template<
typename _Tp>
290 struct is_array<_Tp[]>
294 struct __is_pointer_helper
297 template<
typename _Tp>
298 struct __is_pointer_helper<_Tp*>
302 template<
typename _Tp>
305 remove_cv<_Tp>::type>::value)>
313 template<
typename _Tp>
322 template<
typename _Tp>
330 struct __is_member_object_pointer_helper
333 template<
typename _Tp,
typename _Cp>
334 struct __is_member_object_pointer_helper<_Tp _Cp::*>
338 template<
typename _Tp>
341 typename remove_cv<_Tp>::type>::value)>
345 struct __is_member_function_pointer_helper
348 template<
typename _Tp,
typename _Cp>
349 struct __is_member_function_pointer_helper<_Tp _Cp::*>
350 :
public integral_constant<bool, is_function<_Tp>::value> { };
353 template<
typename _Tp>
356 typename remove_cv<_Tp>::type>::value)>
360 template<
typename _Tp>
366 template<
typename _Tp>
372 template<
typename _Tp>
382 template<
typename _Res,
typename... _ArgTypes>
383 struct is_function<_Res(_ArgTypes...)>
386 template<
typename _Res,
typename... _ArgTypes>
387 struct is_function<_Res(_ArgTypes......)>
390 template<
typename _Res,
typename... _ArgTypes>
391 struct is_function<_Res(_ArgTypes...) const>
394 template<
typename _Res,
typename... _ArgTypes>
395 struct is_function<_Res(_ArgTypes......) const>
398 template<
typename _Res,
typename... _ArgTypes>
399 struct is_function<_Res(_ArgTypes...) volatile>
402 template<
typename _Res,
typename... _ArgTypes>
403 struct is_function<_Res(_ArgTypes......) volatile>
406 template<
typename _Res,
typename... _ArgTypes>
407 struct is_function<_Res(_ArgTypes...) const volatile>
410 template<
typename _Res,
typename... _ArgTypes>
411 struct is_function<_Res(_ArgTypes......) const volatile>
415 struct __is_nullptr_t_helper
419 struct __is_nullptr_t_helper<std::nullptr_t>
423 template<
typename _Tp>
424 struct __is_nullptr_t
425 :
public integral_constant<bool, (__is_nullptr_t_helper<typename
426 remove_cv<_Tp>::type>::value)>
432 template<
typename _Tp>
434 :
public __or_<is_lvalue_reference<_Tp>,
435 is_rvalue_reference<_Tp>>::type
439 template<
typename _Tp>
441 :
public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type
445 template<
typename _Tp>
447 :
public __or_<is_arithmetic<_Tp>, is_void<_Tp>, __is_nullptr_t<_Tp>>::type
451 template<
typename _Tp>
453 :
public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
461 template<
typename _Tp>
463 :
public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
464 is_member_pointer<_Tp>, __is_nullptr_t<_Tp>>::type
468 template<
typename _Tp>
472 template<
typename _Tp>
473 struct __is_member_pointer_helper
476 template<
typename _Tp,
typename _Cp>
477 struct __is_member_pointer_helper<_Tp _Cp::*>
481 template<
typename _Tp>
482 struct is_member_pointer
483 :
public integral_constant<bool, (__is_member_pointer_helper<
484 typename remove_cv<_Tp>::type>::value)>
494 template<
typename _Tp>
503 template<
typename _Tp>
508 template<
typename _Tp>
516 template<
typename _Tp>
523 template<
typename _Tp>
529 template<
typename _Tp>
535 template<
typename _Tp>
541 template<
typename _Tp>
547 template<
typename _Tp>
552 template<
typename _Tp,
555 struct __is_signed_helper
558 template<
typename _Tp>
559 struct __is_signed_helper<_Tp, false, true>
562 template<
typename _Tp>
563 struct __is_signed_helper<_Tp, true, false>
564 :
public integral_constant<bool, static_cast<bool>(_Tp(-1) < _Tp(0))>
568 template<typename _Tp>
570 : public integral_constant<bool, __is_signed_helper<_Tp>::value>
574 template<typename _Tp>
576 : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>::type
583 struct add_rvalue_reference;
589 template<typename _Tp>
590 typename add_rvalue_reference<_Tp>::type declval() noexcept;
592 template<typename, unsigned = 0>
596 struct remove_all_extents;
598 template<typename _Tp>
599 struct __is_array_known_bounds
600 : public integral_constant<bool, (extent<_Tp>::value > 0)>
603 template<
typename _Tp>
604 struct __is_array_unknown_bounds
605 :
public __and_<is_array<_Tp>, __not_<extent<_Tp>>>::type
613 struct __do_is_destructible_impl
615 template<
typename _Tp,
typename = decltype(declval<_Tp&>().~_Tp())>
622 template<
typename _Tp>
623 struct __is_destructible_impl
624 :
public __do_is_destructible_impl
626 typedef decltype(__test<_Tp>(0)) type;
629 template<typename _Tp,
630 bool = __or_<is_void<_Tp>,
631 __is_array_unknown_bounds<_Tp>,
632 is_function<_Tp>>::value,
633 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
634 struct __is_destructible_safe;
636 template<typename _Tp>
637 struct __is_destructible_safe<_Tp, false, false>
638 : public __is_destructible_impl<typename
639 remove_all_extents<_Tp>::type>::type
642 template<
typename _Tp>
643 struct __is_destructible_safe<_Tp, true, false>
646 template<
typename _Tp>
647 struct __is_destructible_safe<_Tp, false, true>
651 template<
typename _Tp>
660 struct __do_is_nt_destructible_impl
662 template<
typename _Tp>
670 template<
typename _Tp>
671 struct __is_nt_destructible_impl
672 :
public __do_is_nt_destructible_impl
674 typedef decltype(__test<_Tp>(0)) type;
677 template<typename _Tp,
678 bool = __or_<is_void<_Tp>,
679 __is_array_unknown_bounds<_Tp>,
680 is_function<_Tp>>::value,
681 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
682 struct __is_nt_destructible_safe;
684 template<typename _Tp>
685 struct __is_nt_destructible_safe<_Tp, false, false>
686 : public __is_nt_destructible_impl<typename
687 remove_all_extents<_Tp>::type>::type
690 template<
typename _Tp>
691 struct __is_nt_destructible_safe<_Tp, true, false>
694 template<
typename _Tp>
695 struct __is_nt_destructible_safe<_Tp, false, true>
699 template<
typename _Tp>
704 struct __do_is_default_constructible_impl
706 template<
typename _Tp,
typename = decltype(_Tp())>
713 template<
typename _Tp>
714 struct __is_default_constructible_impl
715 :
public __do_is_default_constructible_impl
717 typedef decltype(__test<_Tp>(0)) type;
720 template<typename _Tp>
721 struct __is_default_constructible_atom
722 : public __and_<__not_<is_void<_Tp>>,
723 __is_default_constructible_impl<_Tp>>::type
726 template<typename _Tp, bool = is_array<_Tp>::value>
727 struct __is_default_constructible_safe;
734 template<
typename _Tp>
735 struct __is_default_constructible_safe<_Tp, true>
736 :
public __and_<__is_array_known_bounds<_Tp>,
737 __is_default_constructible_atom<typename
738 remove_all_extents<_Tp>::type>>::type
741 template<
typename _Tp>
742 struct __is_default_constructible_safe<_Tp, false>
743 :
public __is_default_constructible_atom<_Tp>::type
747 template<
typename _Tp>
765 struct __do_is_static_castable_impl
767 template<
typename _From,
typename _To,
typename
768 = decltype(static_cast<_To>(declval<_From>()))>
771 template<
typename,
typename>
775 template<
typename _From,
typename _To>
776 struct __is_static_castable_impl
777 :
public __do_is_static_castable_impl
779 typedef decltype(__test<_From, _To>(0)) type;
782 template<typename _From, typename _To>
783 struct __is_static_castable_safe
784 : public __is_static_castable_impl<_From, _To>::type
788 template<
typename _From,
typename _To>
789 struct __is_static_castable
790 :
public integral_constant<bool, (__is_static_castable_safe<
799 struct __do_is_direct_constructible_impl
801 template<
typename _Tp,
typename _Arg,
typename
802 = decltype(::
new _Tp(declval<_Arg>()))>
805 template<
typename,
typename>
809 template<
typename _Tp,
typename _Arg>
810 struct __is_direct_constructible_impl
811 :
public __do_is_direct_constructible_impl
813 typedef decltype(__test<_Tp, _Arg>(0)) type;
816 template<typename _Tp, typename _Arg>
817 struct __is_direct_constructible_new_safe
818 : public __and_<is_destructible<_Tp>,
819 __is_direct_constructible_impl<_Tp, _Arg>>::type
822 template<
typename,
typename>
825 template<
typename,
typename>
831 template<
typename _From,
typename _To,
bool
832 = __not_<__or_<is_void<_From>,
834 struct __is_base_to_derived_ref;
838 template<
typename _From,
typename _To>
839 struct __is_base_to_derived_ref<_From, _To, true>
842 >::type>::type __src_t;
844 >::type>::type __dst_t;
845 typedef __and_<__not_<is_same<__src_t, __dst_t>>,
847 static constexpr
bool value = type::value;
850 template<
typename _From,
typename _To>
851 struct __is_base_to_derived_ref<_From, _To, false>
855 template<
typename _From,
typename _To,
bool
856 = __and_<is_lvalue_reference<_From>,
857 is_rvalue_reference<_To>>::value>
858 struct __is_lvalue_to_rvalue_ref;
862 template<
typename _From,
typename _To>
863 struct __is_lvalue_to_rvalue_ref<_From, _To, true>
865 typedef typename remove_cv<
typename remove_reference<
866 _From>::type>::type __src_t;
867 typedef typename remove_cv<
typename remove_reference<
868 _To>::type>::type __dst_t;
869 typedef __and_<__not_<is_function<__src_t>>,
870 __or_<is_same<__src_t, __dst_t>,
871 is_base_of<__dst_t, __src_t>>> type;
872 static constexpr
bool value = type::value;
875 template<
typename _From,
typename _To>
876 struct __is_lvalue_to_rvalue_ref<_From, _To, false>
886 template<
typename _Tp,
typename _Arg>
887 struct __is_direct_constructible_ref_cast
888 :
public __and_<__is_static_castable<_Arg, _Tp>,
889 __not_<__or_<__is_base_to_derived_ref<_Arg, _Tp>,
890 __is_lvalue_to_rvalue_ref<_Arg, _Tp>
894 template<
typename _Tp,
typename _Arg>
895 struct __is_direct_constructible_new
896 :
public conditional<is_reference<_Tp>::value,
897 __is_direct_constructible_ref_cast<_Tp, _Arg>,
898 __is_direct_constructible_new_safe<_Tp, _Arg>
902 template<
typename _Tp,
typename _Arg>
903 struct __is_direct_constructible
904 :
public integral_constant<bool, (__is_direct_constructible_new<
913 struct __do_is_nary_constructible_impl
915 template<
typename _Tp,
typename... _Args,
typename
916 = decltype(_Tp(declval<_Args>()...))>
919 template<
typename,
typename...>
923 template<
typename _Tp,
typename... _Args>
924 struct __is_nary_constructible_impl
925 :
public __do_is_nary_constructible_impl
927 typedef decltype(__test<_Tp, _Args...>(0)) type;
930 template<typename _Tp, typename... _Args>
931 struct __is_nary_constructible
932 : public __is_nary_constructible_impl<_Tp, _Args...>::type
934 static_assert(
sizeof...(_Args) > 1,
935 "Only useful for > 1 arguments");
938 template<
typename _Tp,
typename... _Args>
939 struct __is_constructible_impl
940 :
public __is_nary_constructible<_Tp, _Args...>
943 template<
typename _Tp,
typename _Arg>
944 struct __is_constructible_impl<_Tp, _Arg>
945 :
public __is_direct_constructible<_Tp, _Arg>
948 template<
typename _Tp>
949 struct __is_constructible_impl<_Tp>
950 :
public is_default_constructible<_Tp>
954 template<
typename _Tp,
typename... _Args>
960 template<typename _Tp, bool = is_void<_Tp>::value>
961 struct __is_copy_constructible_impl;
963 template<
typename _Tp>
964 struct __is_copy_constructible_impl<_Tp, true>
967 template<
typename _Tp>
968 struct __is_copy_constructible_impl<_Tp, false>
969 :
public is_constructible<_Tp, const _Tp&>
973 template<
typename _Tp>
975 :
public __is_copy_constructible_impl<_Tp>
978 template<typename _Tp, bool = is_void<_Tp>::value>
979 struct __is_move_constructible_impl;
981 template<
typename _Tp>
982 struct __is_move_constructible_impl<_Tp, true>
985 template<
typename _Tp>
986 struct __is_move_constructible_impl<_Tp, false>
987 :
public is_constructible<_Tp, _Tp&&>
991 template<
typename _Tp>
993 :
public __is_move_constructible_impl<_Tp>
996 template<
typename _Tp>
997 struct __is_nt_default_constructible_atom
1001 template<typename _Tp, bool = is_array<_Tp>::value>
1002 struct __is_nt_default_constructible_impl;
1004 template<
typename _Tp>
1005 struct __is_nt_default_constructible_impl<_Tp, true>
1006 :
public __and_<__is_array_known_bounds<_Tp>,
1007 __is_nt_default_constructible_atom<typename
1008 remove_all_extents<_Tp>::type>>::type
1011 template<
typename _Tp>
1012 struct __is_nt_default_constructible_impl<_Tp, false>
1013 :
public __is_nt_default_constructible_atom<_Tp>
1017 template<
typename _Tp>
1019 :
public __and_<is_default_constructible<_Tp>,
1020 __is_nt_default_constructible_impl<_Tp>>::type
1023 template<
typename _Tp,
typename... _Args>
1024 struct __is_nt_constructible_impl
1028 template<
typename _Tp,
typename _Arg>
1029 struct __is_nt_constructible_impl<_Tp, _Arg>
1030 :
public integral_constant<bool,
1031 noexcept(static_cast<_Tp>(declval<_Arg>()))>
1034 template<
typename _Tp>
1035 struct __is_nt_constructible_impl<_Tp>
1036 :
public is_nothrow_default_constructible<_Tp>
1040 template<
typename _Tp,
typename... _Args>
1042 :
public __and_<is_constructible<_Tp, _Args...>,
1043 __is_nt_constructible_impl<_Tp, _Args...>>::type
1046 template<typename _Tp, bool = is_void<_Tp>::value>
1047 struct __is_nothrow_copy_constructible_impl;
1049 template<
typename _Tp>
1050 struct __is_nothrow_copy_constructible_impl<_Tp, true>
1053 template<
typename _Tp>
1054 struct __is_nothrow_copy_constructible_impl<_Tp, false>
1055 :
public is_nothrow_constructible<_Tp, const _Tp&>
1059 template<
typename _Tp>
1061 :
public __is_nothrow_copy_constructible_impl<_Tp>
1064 template<typename _Tp, bool = is_void<_Tp>::value>
1065 struct __is_nothrow_move_constructible_impl;
1067 template<
typename _Tp>
1068 struct __is_nothrow_move_constructible_impl<_Tp, true>
1071 template<
typename _Tp>
1072 struct __is_nothrow_move_constructible_impl<_Tp, false>
1073 :
public is_nothrow_constructible<_Tp, _Tp&&>
1077 template<
typename _Tp>
1079 :
public __is_nothrow_move_constructible_impl<_Tp>
1082 template<
typename _Tp,
typename _Up>
1083 class __is_assignable_helper
1084 :
public __sfinae_types
1086 template<
typename _Tp1,
typename _Up1>
1087 static decltype(declval<_Tp1>() = declval<_Up1>(), __one())
1090 template<typename, typename>
1091 static __two __test(...);
1094 static constexpr
bool value = sizeof(__test<_Tp, _Up>(0)) == 1;
1098 template<typename _Tp, typename _Up>
1101 __is_assignable_helper<_Tp, _Up>::value>
1104 template<typename _Tp, bool = is_void<_Tp>::value>
1105 struct __is_copy_assignable_impl;
1107 template<
typename _Tp>
1108 struct __is_copy_assignable_impl<_Tp, true>
1111 template<
typename _Tp>
1112 struct __is_copy_assignable_impl<_Tp, false>
1113 :
public is_assignable<_Tp&, const _Tp&>
1117 template<
typename _Tp>
1119 :
public __is_copy_assignable_impl<_Tp>
1122 template<typename _Tp, bool = is_void<_Tp>::value>
1123 struct __is_move_assignable_impl;
1125 template<
typename _Tp>
1126 struct __is_move_assignable_impl<_Tp, true>
1129 template<
typename _Tp>
1130 struct __is_move_assignable_impl<_Tp, false>
1131 :
public is_assignable<_Tp&, _Tp&&>
1135 template<
typename _Tp>
1137 :
public __is_move_assignable_impl<_Tp>
1140 template<
typename _Tp,
typename _Up>
1141 struct __is_nt_assignable_impl
1146 template<
typename _Tp,
typename _Up>
1148 :
public __and_<is_assignable<_Tp, _Up>,
1149 __is_nt_assignable_impl<_Tp, _Up>>::type
1152 template<typename _Tp, bool = is_void<_Tp>::value>
1153 struct __is_nt_copy_assignable_impl;
1155 template<
typename _Tp>
1156 struct __is_nt_copy_assignable_impl<_Tp, true>
1159 template<
typename _Tp>
1160 struct __is_nt_copy_assignable_impl<_Tp, false>
1161 :
public is_nothrow_assignable<_Tp&, const _Tp&>
1165 template<
typename _Tp>
1167 :
public __is_nt_copy_assignable_impl<_Tp>
1170 template<typename _Tp, bool = is_void<_Tp>::value>
1171 struct __is_nt_move_assignable_impl;
1173 template<
typename _Tp>
1174 struct __is_nt_move_assignable_impl<_Tp, true>
1177 template<
typename _Tp>
1178 struct __is_nt_move_assignable_impl<_Tp, false>
1179 :
public is_nothrow_assignable<_Tp&, _Tp&&>
1183 template<
typename _Tp>
1185 :
public __is_nt_move_assignable_impl<_Tp>
1203 template<
typename _Tp>
1205 :
public __and_<is_destructible<_Tp>, integral_constant<bool,
1206 __has_trivial_destructor(_Tp)>>::type
1210 template<
typename _Tp>
1216 template<
typename _Tp>
1222 template<
typename _Tp>
1228 template<
typename _Tp>
1237 template<
typename _Tp>
1246 template<
typename _Tp, std::
size_t _Size>
1247 struct rank<_Tp[_Size]>
1250 template<
typename _Tp>
1252 :
public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1255 template<
typename,
unsigned _U
int>
1257 :
public integral_constant<std::size_t, 0> { };
1259 template<
typename _Tp,
unsigned _U
int, std::
size_t _Size>
1260 struct extent<_Tp[_Size], _Uint>
1261 :
public integral_constant<std::size_t,
1262 _Uint == 0 ? _Size : extent<_Tp,
1266 template<
typename _Tp,
unsigned _U
int>
1267 struct extent<_Tp[], _Uint>
1268 :
public integral_constant<std::size_t,
1269 _Uint == 0 ? 0 : extent<_Tp,
1277 template<
typename,
typename>
1281 template<
typename _Tp>
1282 struct is_same<_Tp, _Tp>
1286 template<
typename _Base,
typename _Derived>
1288 :
public integral_constant<bool, __is_base_of(_Base, _Derived)>
1291 template<
typename _From,
typename _To,
1292 bool = __or_<is_void<_From>, is_function<_To>,
1293 is_array<_To>>::value>
1294 struct __is_convertible_helper
1295 {
static constexpr
bool value = is_void<_To>::value; };
1297 template<
typename _From,
typename _To>
1298 class __is_convertible_helper<_From, _To, false>
1299 :
public __sfinae_types
1301 template<
typename _To1>
1302 static void __test_aux(_To1);
1304 template<
typename _From1,
typename _To1>
1305 static decltype(__test_aux<_To1>(std::declval<_From1>()), __one())
1308 template<typename, typename>
1309 static __two __test(...);
1312 static constexpr
bool value = sizeof(__test<_From, _To>(0)) == 1;
1316 template<typename _From, typename _To>
1319 __is_convertible_helper<_From, _To>::value>
1326 template<
typename _Tp>
1328 {
typedef _Tp type; };
1330 template<
typename _Tp>
1332 {
typedef _Tp type; };
1335 template<
typename _Tp>
1337 {
typedef _Tp type; };
1339 template<
typename _Tp>
1341 {
typedef _Tp type; };
1344 template<
typename _Tp>
1348 remove_const<typename remove_volatile<_Tp>::type>::type type;
1352 template<
typename _Tp>
1354 {
typedef _Tp
const type; };
1357 template<
typename _Tp>
1359 {
typedef _Tp
volatile type; };
1362 template<
typename _Tp>
1373 template<
typename _Tp>
1375 {
typedef _Tp type; };
1377 template<
typename _Tp>
1378 struct remove_reference<_Tp&>
1379 {
typedef _Tp type; };
1381 template<
typename _Tp>
1382 struct remove_reference<_Tp&&>
1383 {
typedef _Tp type; };
1385 template<
typename _Tp,
1386 bool = __and_<__not_<is_reference<_Tp>>,
1387 __not_<is_void<_Tp>>>::value,
1388 bool = is_rvalue_reference<_Tp>::value>
1389 struct __add_lvalue_reference_helper
1390 {
typedef _Tp type; };
1392 template<
typename _Tp>
1393 struct __add_lvalue_reference_helper<_Tp, true, false>
1394 {
typedef _Tp& type; };
1396 template<
typename _Tp>
1397 struct __add_lvalue_reference_helper<_Tp, false, true>
1398 {
typedef typename remove_reference<_Tp>::type& type; };
1401 template<
typename _Tp>
1403 :
public __add_lvalue_reference_helper<_Tp>
1406 template<
typename _Tp,
1407 bool = __and_<__not_<is_reference<_Tp>>,
1408 __not_<is_void<_Tp>>>::value>
1409 struct __add_rvalue_reference_helper
1410 {
typedef _Tp type; };
1412 template<
typename _Tp>
1413 struct __add_rvalue_reference_helper<_Tp, true>
1414 {
typedef _Tp&& type; };
1417 template<
typename _Tp>
1418 struct add_rvalue_reference
1419 :
public __add_rvalue_reference_helper<_Tp>
1426 template<
typename _Unqualified,
bool _IsConst,
bool _IsVol>
1427 struct __cv_selector;
1429 template<
typename _Unqualified>
1430 struct __cv_selector<_Unqualified, false, false>
1431 {
typedef _Unqualified __type; };
1433 template<
typename _Unqualified>
1434 struct __cv_selector<_Unqualified, false, true>
1435 {
typedef volatile _Unqualified __type; };
1437 template<
typename _Unqualified>
1438 struct __cv_selector<_Unqualified, true, false>
1439 {
typedef const _Unqualified __type; };
1441 template<
typename _Unqualified>
1442 struct __cv_selector<_Unqualified, true, true>
1443 {
typedef const volatile _Unqualified __type; };
1445 template<
typename _Qualified,
typename _Unqualified,
1446 bool _IsConst = is_const<_Qualified>::value,
1447 bool _IsVol = is_volatile<_Qualified>::value>
1448 class __match_cv_qualifiers
1450 typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match;
1453 typedef typename __match::__type __type;
1457 template<
typename _Tp>
1458 struct __make_unsigned
1459 {
typedef _Tp __type; };
1462 struct __make_unsigned<char>
1463 {
typedef unsigned char __type; };
1466 struct __make_unsigned<signed char>
1467 {
typedef unsigned char __type; };
1470 struct __make_unsigned<short>
1471 {
typedef unsigned short __type; };
1474 struct __make_unsigned<int>
1475 {
typedef unsigned int __type; };
1478 struct __make_unsigned<long>
1479 {
typedef unsigned long __type; };
1482 struct __make_unsigned<long long>
1483 {
typedef unsigned long long __type; };
1485 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
1487 struct __make_unsigned<__int128>
1488 {
typedef unsigned __int128 __type; };
1492 template<
typename _Tp,
1493 bool _IsInt = is_integral<_Tp>::value,
1494 bool _IsEnum = is_enum<_Tp>::value>
1495 class __make_unsigned_selector;
1497 template<
typename _Tp>
1498 class __make_unsigned_selector<_Tp, true, false>
1500 typedef __make_unsigned<typename remove_cv<_Tp>::type> __unsignedt;
1501 typedef typename __unsignedt::__type __unsigned_type;
1502 typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
1505 typedef typename __cv_unsigned::__type __type;
1508 template<
typename _Tp>
1509 class __make_unsigned_selector<_Tp, false, true>
1512 typedef unsigned char __smallest;
1513 static const bool __b0 =
sizeof(_Tp) <=
sizeof(__smallest);
1514 static const bool __b1 =
sizeof(_Tp) <=
sizeof(
unsigned short);
1515 static const bool __b2 =
sizeof(_Tp) <=
sizeof(
unsigned int);
1516 typedef conditional<__b2, unsigned int, unsigned long> __cond2;
1517 typedef typename __cond2::type __cond2_type;
1518 typedef conditional<__b1, unsigned short, __cond2_type> __cond1;
1519 typedef typename __cond1::type __cond1_type;
1522 typedef typename conditional<__b0, __smallest, __cond1_type>::type __type;
1529 template<
typename _Tp>
1531 {
typedef typename __make_unsigned_selector<_Tp>::__type type; };
1539 template<
typename _Tp>
1540 struct __make_signed
1541 {
typedef _Tp __type; };
1544 struct __make_signed<char>
1545 {
typedef signed char __type; };
1548 struct __make_signed<unsigned char>
1549 {
typedef signed char __type; };
1552 struct __make_signed<unsigned short>
1553 {
typedef signed short __type; };
1556 struct __make_signed<unsigned int>
1557 {
typedef signed int __type; };
1560 struct __make_signed<unsigned long>
1561 {
typedef signed long __type; };
1564 struct __make_signed<unsigned long long>
1565 {
typedef signed long long __type; };
1567 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
1569 struct __make_signed<unsigned __int128>
1570 {
typedef __int128 __type; };
1574 template<
typename _Tp,
1575 bool _IsInt = is_integral<_Tp>::value,
1576 bool _IsEnum = is_enum<_Tp>::value>
1577 class __make_signed_selector;
1579 template<
typename _Tp>
1580 class __make_signed_selector<_Tp, true, false>
1582 typedef __make_signed<typename remove_cv<_Tp>::type> __signedt;
1583 typedef typename __signedt::__type __signed_type;
1584 typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed;
1587 typedef typename __cv_signed::__type __type;
1590 template<
typename _Tp>
1591 class __make_signed_selector<_Tp, false, true>
1594 typedef signed char __smallest;
1595 static const bool __b0 =
sizeof(_Tp) <=
sizeof(__smallest);
1596 static const bool __b1 =
sizeof(_Tp) <=
sizeof(
signed short);
1597 static const bool __b2 =
sizeof(_Tp) <=
sizeof(
signed int);
1598 typedef conditional<__b2, signed int, signed long> __cond2;
1599 typedef typename __cond2::type __cond2_type;
1600 typedef conditional<__b1, signed short, __cond2_type> __cond1;
1601 typedef typename __cond1::type __cond1_type;
1604 typedef typename conditional<__b0, __smallest, __cond1_type>::type __type;
1611 template<
typename _Tp>
1613 {
typedef typename __make_signed_selector<_Tp>::__type type; };
1623 template<
typename _Tp>
1625 {
typedef _Tp type; };
1627 template<
typename _Tp, std::
size_t _Size>
1629 {
typedef _Tp type; };
1631 template<
typename _Tp>
1632 struct remove_extent<_Tp[]>
1633 {
typedef _Tp type; };
1636 template<
typename _Tp>
1637 struct remove_all_extents
1638 {
typedef _Tp type; };
1640 template<
typename _Tp, std::
size_t _Size>
1641 struct remove_all_extents<_Tp[_Size]>
1642 {
typedef typename remove_all_extents<_Tp>::type type; };
1644 template<
typename _Tp>
1645 struct remove_all_extents<_Tp[]>
1646 {
typedef typename remove_all_extents<_Tp>::type type; };
1651 template<
typename _Tp,
typename>
1652 struct __remove_pointer_helper
1653 {
typedef _Tp type; };
1655 template<
typename _Tp,
typename _Up>
1656 struct __remove_pointer_helper<_Tp, _Up*>
1657 {
typedef _Up type; };
1660 template<
typename _Tp>
1662 :
public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
1666 template<
typename _Tp>
1668 {
typedef typename remove_reference<_Tp>::type* type; };
1671 template<std::
size_t _Len>
1672 struct __aligned_storage_msa
1676 unsigned char __data[_Len];
1677 struct __attribute__((__aligned__)) { } __align;
1691 template<std::size_t _Len, std::size_t _Align =
1692 __alignof__(
typename __aligned_storage_msa<_Len>::__type)>
1697 unsigned char __data[_Len];
1698 struct __attribute__((__aligned__((_Align)))) { } __align;
1705 template<
typename _Up,
1708 struct __decay_selector;
1711 template<
typename _Up>
1712 struct __decay_selector<_Up, false, false>
1713 {
typedef typename remove_cv<_Up>::type __type; };
1715 template<
typename _Up>
1716 struct __decay_selector<_Up, true, false>
1717 {
typedef typename remove_extent<_Up>::type* __type; };
1719 template<
typename _Up>
1720 struct __decay_selector<_Up, false, true>
1721 {
typedef typename add_pointer<_Up>::type __type; };
1724 template<
typename _Tp>
1727 typedef typename remove_reference<_Tp>::type __remove_type;
1730 typedef typename __decay_selector<__remove_type>::__type type;
1733 template<
typename _Tp>
1737 template<
typename _Tp>
1738 struct __strip_reference_wrapper
1743 template<
typename _Tp>
1744 struct __strip_reference_wrapper<reference_wrapper<_Tp> >
1746 typedef _Tp& __type;
1749 template<
typename _Tp>
1750 struct __strip_reference_wrapper<const reference_wrapper<_Tp> >
1752 typedef _Tp& __type;
1755 template<
typename _Tp>
1756 struct __decay_and_strip
1758 typedef typename __strip_reference_wrapper<
1759 typename decay<_Tp>::type>::__type __type;
1765 template<
bool,
typename _Tp =
void>
1770 template<
typename _Tp>
1772 {
typedef _Tp type; };
1774 template<
typename... _Cond>
1775 using _Require =
typename enable_if<__and_<_Cond...>::value>::type;
1779 template<
bool _Cond,
typename _Iftrue,
typename _Iffalse>
1781 {
typedef _Iftrue type; };
1784 template<
typename _Iftrue,
typename _Iffalse>
1785 struct conditional<false, _Iftrue, _Iffalse>
1786 {
typedef _Iffalse type; };
1789 template<
typename... _Tp>
1794 struct __do_common_type_impl
1796 template<
typename _Tp,
typename _Up>
1797 static __success_type<
typename decay<decltype
1798 (
true ? std::declval<_Tp>()
1799 : std::declval<_Up>())>::type> _S_test(
int);
1801 template<
typename,
typename>
1802 static __failure_type _S_test(...);
1805 template<
typename _Tp,
typename _Up>
1806 struct __common_type_impl
1807 :
private __do_common_type_impl
1809 typedef decltype(_S_test<_Tp, _Up>(0)) type;
1812 struct __do_member_type_wrapper
1814 template<
typename _Tp>
1815 static __success_type<typename _Tp::type> _S_test(
int);
1818 static __failure_type _S_test(...);
1821 template<
typename _Tp>
1822 struct __member_type_wrapper
1823 :
private __do_member_type_wrapper
1825 typedef decltype(_S_test<_Tp>(0)) type;
1828 template<typename _CTp, typename... _Args>
1829 struct __expanded_common_type_wrapper
1831 typedef common_type<
typename _CTp::type, _Args...> type;
1834 template<
typename... _Args>
1835 struct __expanded_common_type_wrapper<__failure_type, _Args...>
1836 {
typedef __failure_type type; };
1838 template<
typename _Tp>
1839 struct common_type<_Tp>
1840 {
typedef typename decay<_Tp>::type type; };
1842 template<
typename _Tp,
typename _Up>
1843 struct common_type<_Tp, _Up>
1844 :
public __common_type_impl<_Tp, _Up>::type
1847 template<
typename _Tp,
typename _Up,
typename... _Vp>
1848 struct common_type<_Tp, _Up, _Vp...>
1849 :
public __expanded_common_type_wrapper<typename __member_type_wrapper<
1850 common_type<_Tp, _Up>>::type, _Vp...>::type
1854 template<
typename _Tp>
1857 typedef __underlying_type(_Tp) type;
1860 template<
typename _Tp>
1861 struct __declval_protector
1863 static const bool __stop =
false;
1864 static typename add_rvalue_reference<_Tp>::type __delegate();
1867 template<
typename _Tp>
1868 inline typename add_rvalue_reference<_Tp>::type
1871 static_assert(__declval_protector<_Tp>::__stop,
1872 "declval() must not be used!");
1873 return __declval_protector<_Tp>::__delegate();
1877 template<
typename _Signature>
1883 struct __result_of_memfun_ref_impl
1885 template<
typename _Fp,
typename _Tp1,
typename... _Args>
1886 static __success_type<decltype(
1887 (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...)
1890 template<
typename...>
1891 static __failure_type _S_test(...);
1894 template<
typename _MemPtr,
typename _Arg,
typename... _Args>
1895 struct __result_of_memfun_ref
1896 :
private __result_of_memfun_ref_impl
1898 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
1902 struct __result_of_memfun_deref_impl
1904 template<
typename _Fp,
typename _Tp1,
typename... _Args>
1905 static __success_type<decltype(
1906 ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...)
1909 template<
typename...>
1910 static __failure_type _S_test(...);
1913 template<
typename _MemPtr,
typename _Arg,
typename... _Args>
1914 struct __result_of_memfun_deref
1915 :
private __result_of_memfun_deref_impl
1917 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
1921 struct __result_of_memobj_ref_impl
1923 template<
typename _Fp,
typename _Tp1>
1924 static __success_type<decltype(
1925 std::declval<_Tp1>().*std::declval<_Fp>()
1928 template<
typename,
typename>
1929 static __failure_type _S_test(...);
1932 template<
typename _MemPtr,
typename _Arg>
1933 struct __result_of_memobj_ref
1934 :
private __result_of_memobj_ref_impl
1936 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
1940 struct __result_of_memobj_deref_impl
1942 template<
typename _Fp,
typename _Tp1>
1943 static __success_type<decltype(
1944 (*std::declval<_Tp1>()).*std::declval<_Fp>()
1947 template<
typename,
typename>
1948 static __failure_type _S_test(...);
1951 template<
typename _MemPtr,
typename _Arg>
1952 struct __result_of_memobj_deref
1953 :
private __result_of_memobj_deref_impl
1955 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
1958 template<typename _MemPtr, typename _Arg>
1959 struct __result_of_memobj;
1961 template<typename _Res, typename _Class, typename _Arg>
1962 struct __result_of_memobj<_Res _Class::*, _Arg>
1964 typedef typename remove_cv<
typename remove_reference<
1965 _Arg>::type>::type _Argval;
1966 typedef _Res _Class::* _MemPtr;
1967 typedef typename conditional<__or_<is_same<_Argval, _Class>,
1968 is_base_of<_Class, _Argval>>::value,
1969 __result_of_memobj_ref<_MemPtr, _Arg>,
1970 __result_of_memobj_deref<_MemPtr, _Arg>
1974 template<
typename _MemPtr,
typename _Arg,
typename... _Args>
1975 struct __result_of_memfun;
1977 template<
typename _Res,
typename _Class,
typename _Arg,
typename... _Args>
1978 struct __result_of_memfun<_Res _Class::*, _Arg, _Args...>
1980 typedef typename remove_cv<
typename remove_reference<
1981 _Arg>::type>::type _Argval;
1982 typedef _Res _Class::* _MemPtr;
1983 typedef typename conditional<__or_<is_same<_Argval, _Class>,
1984 is_base_of<_Class, _Argval>>::value,
1985 __result_of_memfun_ref<_MemPtr, _Arg, _Args...>,
1986 __result_of_memfun_deref<_MemPtr, _Arg, _Args...>
1990 template<bool, bool,
typename _Functor,
typename... _ArgTypes>
1991 struct __result_of_impl
1993 typedef __failure_type type;
1996 template<
typename _MemPtr,
typename _Arg>
1997 struct __result_of_impl<true, false, _MemPtr, _Arg>
1998 :
public __result_of_memobj<typename decay<_MemPtr>::type, _Arg>
2001 template<
typename _MemPtr,
typename _Arg,
typename... _Args>
2002 struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...>
2003 :
public __result_of_memfun<typename decay<_MemPtr>::type, _Arg, _Args...>
2007 struct __result_of_other_impl
2009 template<
typename _Fn,
typename... _Args>
2010 static __success_type<decltype(
2011 std::declval<_Fn>()(std::declval<_Args>()...)
2014 template<
typename...>
2015 static __failure_type _S_test(...);
2018 template<
typename _Functor,
typename... _ArgTypes>
2019 struct __result_of_impl<false, false, _Functor, _ArgTypes...>
2020 :
private __result_of_other_impl
2022 typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type;
2025 template<typename _Functor, typename... _ArgTypes>
2026 struct result_of<_Functor(_ArgTypes...)>
2027 : public __result_of_impl<
2028 is_member_object_pointer<
2029 typename remove_reference<_Functor>::type
2031 is_member_function_pointer<
2032 typename remove_reference<_Functor>::type
2034 _Functor, _ArgTypes...
2044 #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \
2045 template<typename _Tp> \
2046 class __has_##_NTYPE##_helper \
2049 template<typename _Up> \
2053 template<typename _Up> \
2054 static __one __test(_Wrap_type<typename _Up::_NTYPE>*); \
2056 template<typename _Up> \
2057 static __two __test(...); \
2060 static constexpr bool value = sizeof(__test<_Tp>(0)) == 1; \
2063 template<typename _Tp> \
2064 struct __has_##_NTYPE \
2065 : integral_constant<bool, __has_##_NTYPE##_helper \
2066 <typename remove_cv<_Tp>::type>::value> \
2069 _GLIBCXX_END_NAMESPACE_VERSION
2074 #endif // _GLIBCXX_TYPE_TRAITS