Skip to content

Commit 30cc12c

Browse files
authored
[libc++] Simplify the implementation of is_null_pointer a bit (#98728)
1 parent 0eebb48 commit 30cc12c

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

libcxx/include/__type_traits/is_fundamental.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ inline constexpr bool is_fundamental_v = __is_fundamental(_Tp);
3434

3535
template <class _Tp>
3636
struct _LIBCPP_TEMPLATE_VIS is_fundamental
37-
: public integral_constant<bool, is_void<_Tp>::value || __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {};
37+
: public integral_constant<bool, is_void<_Tp>::value || __is_null_pointer_v<_Tp> || is_arithmetic<_Tp>::value> {};
3838

3939
# if _LIBCPP_STD_VER >= 17
4040
template <class _Tp>

libcxx/include/__type_traits/is_null_pointer.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include <__config>
1313
#include <__type_traits/integral_constant.h>
14-
#include <__type_traits/remove_cv.h>
1514
#include <cstddef>
1615

1716
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -21,20 +20,15 @@
2120
_LIBCPP_BEGIN_NAMESPACE_STD
2221

2322
template <class _Tp>
24-
struct __is_nullptr_t_impl : public false_type {};
25-
template <>
26-
struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
27-
28-
template <class _Tp>
29-
struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {};
23+
inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t);
3024

3125
#if _LIBCPP_STD_VER >= 14
3226
template <class _Tp>
33-
struct _LIBCPP_TEMPLATE_VIS is_null_pointer : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {};
27+
struct _LIBCPP_TEMPLATE_VIS is_null_pointer : integral_constant<bool, __is_null_pointer_v<_Tp>> {};
3428

3529
# if _LIBCPP_STD_VER >= 17
3630
template <class _Tp>
37-
inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
31+
inline constexpr bool is_null_pointer_v = __is_null_pointer_v<_Tp>;
3832
# endif
3933
#endif // _LIBCPP_STD_VER >= 14
4034

libcxx/include/__type_traits/is_scalar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct _LIBCPP_TEMPLATE_VIS is_scalar
4949
bool, is_arithmetic<_Tp>::value ||
5050
is_member_pointer<_Tp>::value ||
5151
is_pointer<_Tp>::value ||
52-
__is_nullptr_t<_Tp>::value ||
52+
__is_null_pointer_v<_Tp> ||
5353
__is_block<_Tp>::value ||
5454
is_enum<_Tp>::value> {};
5555
// clang-format on

0 commit comments

Comments
 (0)