@@ -30,19 +30,39 @@ namespace __math {
30
30
31
31
template <class _A1 , __enable_if_t <is_floating_point<_A1>::value, int > = 0 >
32
32
_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit (_A1 __x) _NOEXCEPT {
33
+ // TODO(LLVM 22): Remove `__builtin_copysign`-workaround once support for Clang 19 is dropped.
34
+ #if !__has_constexpr_builtin(__builtin_signbit) && _LIBCPP_STD_VER >= 23
35
+ return __builtin_copysign (1.0 , __x) == -1.0 ;
36
+ #else
33
37
return __builtin_signbit (__x);
38
+ #endif
34
39
}
35
40
36
41
_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit (float __x) _NOEXCEPT {
42
+ // TODO(LLVM 22): Remove `__builtin_copysign`-workaround once support for Clang 19 is dropped.
43
+ #if !__has_constexpr_builtin(__builtin_signbit) && _LIBCPP_STD_VER >= 23
44
+ return __builtin_copysign (1.0 , __x) == -1.0 ;
45
+ #else
37
46
return __builtin_signbit (__x);
47
+ #endif
38
48
}
39
49
40
50
_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit (double __x) _NOEXCEPT {
51
+ // TODO(LLVM 22): Remove `__builtin_copysign`-workaround once support for Clang 19 is dropped.
52
+ #if !__has_constexpr_builtin(__builtin_signbit) && _LIBCPP_STD_VER >= 23
53
+ return __builtin_copysign (1.0 , __x) == -1.0 ;
54
+ #else
41
55
return __builtin_signbit (__x);
56
+ #endif
42
57
}
43
58
44
59
_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit (long double __x) _NOEXCEPT {
60
+ // TODO(LLVM 22): Remove `__builtin_copysign`-workaround once support for Clang 19 is dropped.
61
+ #if !__has_constexpr_builtin(__builtin_signbit) && _LIBCPP_STD_VER >= 23
62
+ return __builtin_copysign (1.0 , __x) == -1.0 ;
63
+ #else
45
64
return __builtin_signbit (__x);
65
+ #endif
46
66
}
47
67
48
68
template <class _A1 , __enable_if_t <is_integral<_A1>::value && is_signed<_A1>::value, int > = 0 >
0 commit comments