Skip to content

Commit ea66018

Browse files
committed
[libc++] Use variable templates in is_floating_point
1 parent 3226a5f commit ea66018

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

libcxx/include/__type_traits/is_floating_point.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@
2020
_LIBCPP_BEGIN_NAMESPACE_STD
2121

2222
// clang-format off
23-
template <class _Tp> struct __libcpp_is_floating_point : false_type {};
24-
template <> struct __libcpp_is_floating_point<float> : true_type {};
25-
template <> struct __libcpp_is_floating_point<double> : true_type {};
26-
template <> struct __libcpp_is_floating_point<long double> : true_type {};
23+
template <class _Tp> inline const bool __is_floating_point_impl = false;
24+
template <> inline const bool __is_floating_point_impl<float> = true;
25+
template <> inline const bool __is_floating_point_impl<double> = true;
26+
template <> inline const bool __is_floating_point_impl<long double> = true;
2727
// clang-format on
2828

2929
template <class _Tp>
30-
struct _LIBCPP_NO_SPECIALIZATIONS is_floating_point : __libcpp_is_floating_point<__remove_cv_t<_Tp> > {};
30+
struct _LIBCPP_NO_SPECIALIZATIONS is_floating_point
31+
: integral_constant<bool, __is_floating_point_impl<__remove_cv_t<_Tp> > > {};
3132

3233
#if _LIBCPP_STD_VER >= 17
33-
template <class _Tp>
34-
_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
34+
template<class _Tp>
35+
inline constexpr bool is_floating_point_v = __is_floating_point_impl<__remove_cv_t<_Tp>>;
3536
#endif
3637

3738
_LIBCPP_END_NAMESPACE_STD

0 commit comments

Comments
 (0)