From c18c38c4fd7609fdd53ded098472c1b9d626f33f Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Sat, 13 Jul 2024 10:56:34 +0200 Subject: [PATCH] [libc++][NFC] Simplify the implementation of is_null_pointer a bit --- libcxx/include/__type_traits/is_fundamental.h | 2 +- libcxx/include/__type_traits/is_null_pointer.h | 12 +++--------- libcxx/include/__type_traits/is_scalar.h | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/libcxx/include/__type_traits/is_fundamental.h b/libcxx/include/__type_traits/is_fundamental.h index 57206e0d9deb1f..55f8e41f75f457 100644 --- a/libcxx/include/__type_traits/is_fundamental.h +++ b/libcxx/include/__type_traits/is_fundamental.h @@ -34,7 +34,7 @@ inline constexpr bool is_fundamental_v = __is_fundamental(_Tp); template struct _LIBCPP_TEMPLATE_VIS is_fundamental - : public integral_constant::value || __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {}; + : public integral_constant::value || __is_null_pointer_v<_Tp> || is_arithmetic<_Tp>::value> {}; # if _LIBCPP_STD_VER >= 17 template diff --git a/libcxx/include/__type_traits/is_null_pointer.h b/libcxx/include/__type_traits/is_null_pointer.h index c666f5f24759c9..9f5697e232684e 100644 --- a/libcxx/include/__type_traits/is_null_pointer.h +++ b/libcxx/include/__type_traits/is_null_pointer.h @@ -11,7 +11,6 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__type_traits/remove_cv.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -21,20 +20,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD template -struct __is_nullptr_t_impl : public false_type {}; -template <> -struct __is_nullptr_t_impl : public true_type {}; - -template -struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {}; +inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t); #if _LIBCPP_STD_VER >= 14 template -struct _LIBCPP_TEMPLATE_VIS is_null_pointer : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {}; +struct _LIBCPP_TEMPLATE_VIS is_null_pointer : integral_constant> {}; # if _LIBCPP_STD_VER >= 17 template -inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; +inline constexpr bool is_null_pointer_v = __is_null_pointer_v<_Tp>; # endif #endif // _LIBCPP_STD_VER >= 14 diff --git a/libcxx/include/__type_traits/is_scalar.h b/libcxx/include/__type_traits/is_scalar.h index 15f1c71554f220..455200de472089 100644 --- a/libcxx/include/__type_traits/is_scalar.h +++ b/libcxx/include/__type_traits/is_scalar.h @@ -49,7 +49,7 @@ struct _LIBCPP_TEMPLATE_VIS is_scalar bool, is_arithmetic<_Tp>::value || is_member_pointer<_Tp>::value || is_pointer<_Tp>::value || - __is_nullptr_t<_Tp>::value || + __is_null_pointer_v<_Tp> || __is_block<_Tp>::value || is_enum<_Tp>::value> {}; // clang-format on