[libcxx-commits] [libcxx] [libc++] Use variable templates in is_floating_point (PR #167141)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 10 02:11:40 PST 2025
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/167141
>From b43ac972e5bddc633109e7fa154d6072a2f41aa4 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sat, 8 Nov 2025 14:41:07 +0100
Subject: [PATCH] [libc++] Use variable templates in is_floating_point
---
libcxx/include/__type_traits/is_floating_point.h | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
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
More information about the libcxx-commits
mailing list