Skip to content

Commit 8126ad0

Browse files
[libc++] Add std::fpclassify overloads for floating-point.
Standard says that implementation of math functions that have floating-point-type parameter should provide an "overload for each cv-unqualified floating-point type".
1 parent e0cd781 commit 8126ad0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

libcxx/include/math.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,16 @@ namespace __math {
387387

388388
// fpclassify
389389

390-
template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
391-
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
390+
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT {
391+
return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
392+
}
393+
394+
template <class = int>
395+
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT {
396+
return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
397+
}
398+
399+
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT {
392400
return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
393401
}
394402

0 commit comments

Comments
 (0)