[libcxx-commits] [libcxx] [libc++][math] Add `constexpr` to `std::fpclassify` (PR #210993)
Lucas Mellone via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jul 27 06:01:16 PDT 2026
================
@@ -387,26 +387,50 @@ namespace __math {
// fpclassify
+# ifdef _LIBCPP_PREFERRED_OVERLOAD
+[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD int fpclassify(float __x) _NOEXCEPT {
+ return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
+}
+
+[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD int
+fpclassify(double __x) _NOEXCEPT {
+ return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
+}
+
+[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD int
+fpclassify(long double __x) _NOEXCEPT {
+ return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
+}
+
+template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
+[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD int
+fpclassify(_A1 __x) _NOEXCEPT {
+ return __x == 0 ? FP_ZERO : FP_NORMAL;
+}
----------------
lknknm wrote:
Follows up this comment here: https://github.com/llvm/llvm-project/pull/210993#discussion_r3626947336 and https://github.com/llvm/llvm-project/pull/210993#issuecomment-5077628370
I even tried without it but all Windows tests were failing.
https://github.com/llvm/llvm-project/pull/210993
More information about the libcxx-commits
mailing list