-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc++] Simplify the implementation of is_null_pointer a bit #98728
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
llvmbot
added
the
libc++
libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
label
Jul 13, 2024
philnik777
force-pushed
the
simplify_is_null_pointer
branch
from
July 13, 2024 08:57
eac66ce
to
c18c38c
Compare
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesFull diff: https://github.com/llvm/llvm-project/pull/98728.diff 3 Files Affected:
diff --git a/libcxx/include/__type_traits/is_fundamental.h b/libcxx/include/__type_traits/is_fundamental.h
index 57206e0d9deb1..55f8e41f75f45 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 <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_fundamental
- : public integral_constant<bool, is_void<_Tp>::value || __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {};
+ : public integral_constant<bool, is_void<_Tp>::value || __is_null_pointer_v<_Tp> || is_arithmetic<_Tp>::value> {};
# if _LIBCPP_STD_VER >= 17
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_null_pointer.h b/libcxx/include/__type_traits/is_null_pointer.h
index c666f5f24759c..9f5697e232684 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 <cstddef>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -21,20 +20,15 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-struct __is_nullptr_t_impl : public false_type {};
-template <>
-struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
-
-template <class _Tp>
-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 <class _Tp>
-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<bool, __is_null_pointer_v<_Tp>> {};
# if _LIBCPP_STD_VER >= 17
template <class _Tp>
-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 15f1c71554f22..455200de47208 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
|
ldionne
approved these changes
Jul 15, 2024
I would drop NFC from the commit when merging, though. It's not intended to change anything, but it's also not a change to e.g. a comment. |
philnik777
changed the title
[libc++][NFC] Simplify the implementation of is_null_pointer a bit
[libc++] Simplify the implementation of is_null_pointer a bit
Jul 16, 2024
sayhaan
pushed a commit
to sayhaan/llvm-project
that referenced
this pull request
Jul 16, 2024
…8728) Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D59822403
yuxuanchen1997
pushed a commit
that referenced
this pull request
Jul 25, 2024
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251631
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.