Skip to content

Commit d7e4b9b

Browse files
committed
Define overloads as templates
1 parent 9c24e8d commit d7e4b9b

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

libcxx/include/__math/traits.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,21 @@ namespace __math {
3434
# define _LIBCPP_SIGNBIT_CONSTEXPR
3535
#endif
3636

37-
// The universal C runtime (UCRT) in the WinSDK provides overloads for all floating point types
38-
// for std::signbit(). We need to work around it as the compilation would otherwise error out
39-
// due to duplicated definitions for clang-cl builds.
40-
#if defined(_LIBCPP_MSVCRT) && defined(_LIBCPP_PREFERRED_OVERLOAD)
41-
# define LIBCPP_SIGNBIT_OVERLOAD _LIBCPP_PREFERRED_OVERLOAD
42-
#else
43-
# define LIBCPP_SIGNBIT_OVERLOAD
44-
#endif
45-
46-
_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI LIBCPP_SIGNBIT_OVERLOAD bool
47-
signbit(float __x) _NOEXCEPT {
37+
// The universal C runtime (UCRT) in the WinSDK provides floating point overloads
38+
// for std::signbit(). By defining our overloads as templates, we can work around
39+
// this issue as templates are less preferred than non-template functions.
40+
template <class = void>
41+
_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(float __x) _NOEXCEPT {
4842
return __builtin_signbit(__x);
4943
}
5044

51-
_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI LIBCPP_SIGNBIT_OVERLOAD bool
52-
signbit(double __x) _NOEXCEPT {
45+
template <class = void>
46+
_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(double __x) _NOEXCEPT {
5347
return __builtin_signbit(__x);
5448
}
5549

56-
_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI LIBCPP_SIGNBIT_OVERLOAD bool
57-
signbit(long double __x) _NOEXCEPT {
50+
template <class = void>
51+
_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(long double __x) _NOEXCEPT {
5852
return __builtin_signbit(__x);
5953
}
6054

0 commit comments

Comments
 (0)