Skip to content

Commit

Permalink
Remove overloads
Browse files Browse the repository at this point in the history
We will add the overloads in a seperate
patch.
  • Loading branch information
robincaloudis committed Aug 31, 2024
1 parent 8478001 commit ab19b32
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 57 deletions.
44 changes: 1 addition & 43 deletions libcxx/include/__math/traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,56 +30,14 @@ namespace __math {
template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>
_LIBCPP_NODISCARD inline
// TODO(LLVM 22): Remove conditional once support for Clang 19 is dropped.
#if !defined(__clang__) || __has_constexpr_builtin(__builtin_signbit)
#if defined(_LIBCPP_COMPILER_GCC) || __has_constexpr_builtin(__builtin_signbit)
_LIBCPP_CONSTEXPR_SINCE_CXX23
#endif
_LIBCPP_HIDE_FROM_ABI bool
signbit(_A1 __x) _NOEXCEPT {
return __builtin_signbit(__x);
}

_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
#ifdef _LIBCPP_PREFERRED_OVERLOAD
_LIBCPP_PREFERRED_OVERLOAD
#endif
bool
signbit(float __x) _NOEXCEPT {
// TODO(LLVM 22): Remove `__builtin_copysign`-workaround once support for Clang 19 is dropped.
#if !__has_constexpr_builtin(__builtin_signbit) && _LIBCPP_STD_VER >= 23
return __builtin_copysign(1.0, __x) == -1.0;
#else
return __builtin_signbit(__x);
#endif
}

_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
#ifdef _LIBCPP_PREFERRED_OVERLOAD
_LIBCPP_PREFERRED_OVERLOAD
#endif
bool
signbit(double __x) _NOEXCEPT {
// TODO(LLVM 22): Remove `__builtin_copysign`-workaround once support for Clang 19 is dropped.
#if !__has_constexpr_builtin(__builtin_signbit) && _LIBCPP_STD_VER >= 23
return __builtin_copysign(1.0, __x) == -1.0;
#else
return __builtin_signbit(__x);
#endif
}

_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
#ifdef _LIBCPP_PREFERRED_OVERLOAD
_LIBCPP_PREFERRED_OVERLOAD
#endif
bool
signbit(long double __x) _NOEXCEPT {
// TODO(LLVM 22): Remove `__builtin_copysign`-workaround once support for Clang 19 is dropped.
#if !__has_constexpr_builtin(__builtin_signbit) && _LIBCPP_STD_VER >= 23
return __builtin_copysign(1.0, __x) == -1.0;
#else
return __builtin_signbit(__x);
#endif
}

template <class _A1, __enable_if_t<is_integral<_A1>::value && is_signed<_A1>::value, int> = 0>
_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
return __x < 0;
Expand Down
5 changes: 0 additions & 5 deletions libcxx/test/std/numerics/c.math/isnormal.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ struct TestInt {
}
};

template <typename T>
struct ConvertibleTo {
operator T() const { return T(1); }
};

int main(int, char**) {
types::for_each(types::floating_point_types(), TestFloat());
types::for_each(types::integral_types(), TestInt());
Expand Down
9 changes: 0 additions & 9 deletions libcxx/test/std/numerics/c.math/signbit.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,5 @@ int main(int, char**) {
types::for_each(types::floating_point_types(), TestFloat());
types::for_each(types::integral_types(), TestInt());

// Make sure we can call `std::signbit` with convertible types. This checks
// whether overloads for all cv-unqualified floating-point types are working
// as expected.
{
assert(!std::signbit(ConvertibleTo<float>()));
assert(!std::signbit(ConvertibleTo<double>()));
assert(!std::signbit(ConvertibleTo<long double>()));
}

return 0;
}

0 comments on commit ab19b32

Please sign in to comment.