[libc++] Use variable templates in is_floating_point#167141
Merged
philnik777 merged 1 commit intollvm:mainfrom Nov 12, 2025
Merged
[libc++] Use variable templates in is_floating_point#167141philnik777 merged 1 commit intollvm:mainfrom
philnik777 merged 1 commit intollvm:mainfrom
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
ea66018 to
b43ac97
Compare
Member
|
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesFull diff: https://github.com/llvm/llvm-project/pull/167141.diff 1 Files Affected:
diff --git a/libcxx/include/__type_traits/is_floating_point.h b/libcxx/include/__type_traits/is_floating_point.h
index b87363fe5b357..586fce6af60d6 100644
--- a/libcxx/include/__type_traits/is_floating_point.h
+++ b/libcxx/include/__type_traits/is_floating_point.h
@@ -20,18 +20,19 @@
_LIBCPP_BEGIN_NAMESPACE_STD
// clang-format off
-template <class _Tp> struct __libcpp_is_floating_point : false_type {};
-template <> struct __libcpp_is_floating_point<float> : true_type {};
-template <> struct __libcpp_is_floating_point<double> : true_type {};
-template <> struct __libcpp_is_floating_point<long double> : true_type {};
+template <class _Tp> inline const bool __is_floating_point_impl = false;
+template <> inline const bool __is_floating_point_impl<float> = true;
+template <> inline const bool __is_floating_point_impl<double> = true;
+template <> inline const bool __is_floating_point_impl<long double> = true;
// clang-format on
template <class _Tp>
-struct _LIBCPP_NO_SPECIALIZATIONS is_floating_point : __libcpp_is_floating_point<__remove_cv_t<_Tp> > {};
+struct _LIBCPP_NO_SPECIALIZATIONS is_floating_point
+ : integral_constant<bool, __is_floating_point_impl<__remove_cv_t<_Tp> > > {};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_floating_point_v = __is_floating_point_impl<__remove_cv_t<_Tp>>;
#endif
_LIBCPP_END_NAMESPACE_STD
|
git-crd
pushed a commit
to git-crd/crd-llvm-project
that referenced
this pull request
Nov 13, 2025
This file contains hidden or 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
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.