@@ -69,49 +69,30 @@ _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI boo
6969
7070// isinf
7171
72- template <class _A1 , __enable_if_t <is_floating_point <_A1>::value, int > = 0 >
72+ template <class _A1 , __enable_if_t <is_arithmetic <_A1>::value && numeric_limits<_A1>::has_infinity , int > = 0 >
7373_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf (_A1 __x) _NOEXCEPT {
7474 return __builtin_isinf ((typename __promote<_A1>::type)__x);
7575}
7676
77- template <class _A1 , __enable_if_t <is_integral <_A1>::value, int > = 0 >
77+ template <class _A1 , __enable_if_t <is_arithmetic <_A1>::value && !numeric_limits<_A1>::has_infinity , int > = 0 >
7878_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf (_A1) _NOEXCEPT {
7979 return false ;
8080}
8181
82+ #ifdef _LIBCPP_PREFERRED_OVERLOAD
8283_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf (float __x) _NOEXCEPT {
8384 return __builtin_isinf (__x);
8485}
8586
86- _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
87- // When libc++ is layered on top of glibc on Linux, glibc's `math.h` is included. When compiling with
88- // `-std=c++03`, this header brings the function declaration of `isinf(double)` with return type of
89- // `int` into scope. This differs from the C99 standard as only a macro of the form `#define isinf(arg)`
90- // is expected. Therefore, libc++ needs to respect the presense of this `double` overload with return type
91- // `int` and cannot redefine it with return type `bool` like it is supposed to be, as it will conflict with
92- // the declaration already in scope. For `-std=c++11` and beyond this issue is fixed, as glibc guards the
93- // `double` overload of `isinf` by preprocessor macros.
94- //
95- // When libc++ is layered on top of Bionic's libc, `math.h` exposes a function prototype for `isnan(double)`
96- // with return type `int`. This function prototype in Bionic's libc is not guarded by any preprocessor macros
97- // and will therefore conflict.
98- //
99- // `_LIBCPP_PREFERRED_OVERLOAD` specifies that a given overload is a better match than an otherwise equally good
100- // function declaration. This is implemented in modern versions of Clang via `__attribute__((__enable_if__))`, and
101- // not elsewhere. See https://github.com/llvm/llvm-project/commit/5fd17ab1b093f6b59aabb27f6c2c2278e65c2707 for
102- // details. We use `_LIBCPP_PREFERRED_OVERLOAD` to define overloads in the global namespace that displace the
103- // overloads provided by the C libraries mentioned above.
104- #if ((defined(_LIBCPP_CXX03_LANG) && defined(__GLIBC__)) || defined(__BIONIC__)) && defined(_LIBCPP_PREFERRED_OVERLOAD)
105- _LIBCPP_PREFERRED_OVERLOAD
106- #endif
107- bool
108- isinf (double __x) _NOEXCEPT {
87+ _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool
88+ isinf (double __x) _NOEXCEPT {
10989 return __builtin_isinf (__x);
11090}
11191
11292_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf (long double __x) _NOEXCEPT {
11393 return __builtin_isinf (__x);
11494}
95+ #endif
11596
11697// isnan
11798
@@ -125,39 +106,20 @@ _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan
125106 return false ;
126107}
127108
109+ #ifdef _LIBCPP_PREFERRED_OVERLOAD
128110_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan (float __x) _NOEXCEPT {
129111 return __builtin_isnan (__x);
130112}
131113
132- _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
133- // When libc++ is layered on top of glibc on Linux, glibc's `math.h` is included. When compiling with
134- // `-std=c++03`, this header brings the function declaration of `isnan(double)` with return type of
135- // `int` into scope. This differs from the C99 standard as only a macro of the form `#define isnan(arg)`
136- // is expected. Therefore, libc++ needs to respect the presense of this `double` overload with return type
137- // `int` and cannot redefine it with return type `bool` like it is supposed to be, as it will conflict with
138- // the declaration already in scope. For `-std=c++11` and beyond this issue is fixed, as glibc guards the
139- // `double` overload of `isnan` by preprocessor macros.
140- //
141- // When libc++ is layered on top of Bionic's libc, `math.h` exposes a function prototype for `isnan(double)`
142- // with return type `int`. This function prototype in Bionic's libc is not guarded by any preprocessor macros
143- // and will therefore conflict.
144- //
145- // `_LIBCPP_PREFERRED_OVERLOAD` specifies that a given overload is a better match than an otherwise equally good
146- // function declaration. This is implemented in modern versions of Clang via `__attribute__((__enable_if__))`, and
147- // not elsewhere. See https://github.com/llvm/llvm-project/commit/5fd17ab1b093f6b59aabb27f6c2c2278e65c2707 for
148- // details. We use `_LIBCPP_PREFERRED_OVERLOAD` to define overloads in the global namespace that displace the
149- // overloads provided by the C libraries mentioned above.
150- #if ((defined(_LIBCPP_CXX03_LANG) && defined(__GLIBC__)) || defined(__BIONIC__)) && defined(_LIBCPP_PREFERRED_OVERLOAD)
151- _LIBCPP_PREFERRED_OVERLOAD
152- #endif
153- bool
154- isnan (double __x) _NOEXCEPT {
114+ _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool
115+ isnan (double __x) _NOEXCEPT {
155116 return __builtin_isnan (__x);
156117}
157118
158119_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan (long double __x) _NOEXCEPT {
159120 return __builtin_isnan (__x);
160121}
122+ #endif
161123
162124// isnormal
163125
0 commit comments