diff --git a/include/type_traits b/include/type_traits index e0b6f13fa..de54c0567 100644 --- a/include/type_traits +++ b/include/type_traits @@ -886,28 +886,15 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v // is_function -namespace __libcpp_is_function_imp -{ -struct __dummy_type {}; -template char __test(_Tp*); -template char __test(__dummy_type); -template __two __test(...); -template _Tp& __source(int); -template __dummy_type __source(...); -} - -template ::value || - is_union<_Tp>::value || - is_void<_Tp>::value || - is_reference<_Tp>::value || - __is_nullptr_t<_Tp>::value > -struct __libcpp_is_function - : public integral_constant(__libcpp_is_function_imp::__source<_Tp>(0))) == 1> - {}; -template struct __libcpp_is_function<_Tp, true> : public false_type {}; - template struct _LIBCPP_TEMPLATE_VIS is_function - : public __libcpp_is_function<_Tp> {}; + : public _BoolConstant< +#ifdef __clang__ + __is_function(_Tp) +#else + !(is_reference<_Tp>::value || is_const::value) +#endif + > {}; + #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) template @@ -915,27 +902,24 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v = is_function<_Tp>::value; #endif -// is_member_function_pointer - -// template struct __libcpp_is_member_function_pointer : public false_type {}; -// template struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; -// - -template -struct __member_pointer_traits_imp -{ // forward declaration; specializations later +template struct __libcpp_is_member_pointer { + enum { + __is_member = false, + __is_func = false, + __is_obj = false + }; +}; +template struct __libcpp_is_member_pointer<_Tp _Up::*> { + enum { + __is_member = true, + __is_func = is_function<_Tp>::value, + __is_obj = !__is_func, + }; }; -template struct __libcpp_is_member_function_pointer - : public false_type {}; - -template -struct __libcpp_is_member_function_pointer<_Ret _Class::*> - : public is_function<_Ret> {}; - template struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer - : public __libcpp_is_member_function_pointer::type>::type {}; + : public _BoolConstant< __libcpp_is_member_pointer::type>::__is_func > {}; #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) template @@ -945,11 +929,8 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v // is_member_pointer -template struct __libcpp_is_member_pointer : public false_type {}; -template struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {}; - template struct _LIBCPP_TEMPLATE_VIS is_member_pointer - : public __libcpp_is_member_pointer::type> {}; + : public _BoolConstant< __libcpp_is_member_pointer::type>::__is_member > {}; #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) template @@ -960,8 +941,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v // is_member_object_pointer template struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer - : public integral_constant::value && - !is_member_function_pointer<_Tp>::value> {}; + : public _BoolConstant< __libcpp_is_member_pointer::type>::__is_obj > {}; #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) template @@ -1080,16 +1060,9 @@ struct __is_referenceable : integral_constant::value || - is_function<_Tp>::value || - is_const<_Tp>::value > -struct __add_const {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; - -template -struct __add_const<_Tp, false> {typedef _LIBCPP_NODEBUG_TYPE const _Tp type;}; - -template struct _LIBCPP_TEMPLATE_VIS add_const - {typedef _LIBCPP_NODEBUG_TYPE typename __add_const<_Tp>::type type;}; +template struct _LIBCPP_TEMPLATE_VIS add_const { + typedef _LIBCPP_NODEBUG_TYPE const _Tp type; +}; #if _LIBCPP_STD_VER > 11 template using add_const_t = typename add_const<_Tp>::type; @@ -1097,25 +1070,18 @@ template using add_const_t = typename add_const<_Tp>::type; // add_volatile -template ::value || - is_function<_Tp>::value || - is_volatile<_Tp>::value > -struct __add_volatile {typedef _Tp type;}; - -template -struct __add_volatile<_Tp, false> {typedef volatile _Tp type;}; - -template struct _LIBCPP_TEMPLATE_VIS add_volatile - {typedef _LIBCPP_NODEBUG_TYPE typename __add_volatile<_Tp>::type type;}; +template struct _LIBCPP_TEMPLATE_VIS add_volatile { + typedef _LIBCPP_NODEBUG_TYPE volatile _Tp type; +}; #if _LIBCPP_STD_VER > 11 template using add_volatile_t = typename add_volatile<_Tp>::type; #endif // add_cv - -template struct _LIBCPP_TEMPLATE_VIS add_cv - {typedef _LIBCPP_NODEBUG_TYPE typename add_const::type>::type type;}; +template struct _LIBCPP_TEMPLATE_VIS add_cv { + typedef _LIBCPP_NODEBUG_TYPE const volatile _Tp type; +}; #if _LIBCPP_STD_VER > 11 template using add_cv_t = typename add_cv<_Tp>::type; @@ -2307,6 +2273,9 @@ __decay_copy(_Tp&& __t) return _VSTD::forward<_Tp>(__t); } +template +struct __member_pointer_traits_imp; + template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> {