[libc++] [C++20] [P0415] Constexpr for std::complex.
This patch adds constexpr to <complex> header: operators, member operators, and member functions (real, imag, norm, conj).
https://eel.is/c++draft/complex.numbers
https://wg21.link/p0415
Reviewed By: ldionne, #libc
Spies: philnik, danilaml, Quuxplusone, wmaxey, arichardson, libcxx-commits
Differential Revision: https://reviews.llvm.org/D79555
NOKEYCHECK=True
GitOrigin-RevId: 7223bcf04c4ce3c1585df9408c6a6663cc8364ea
diff --git a/include/math.h b/include/math.h
index 14fa9e2..1636ec4 100644
--- a/include/math.h
+++ b/include/math.h
@@ -1043,43 +1043,12 @@
// copysign
-_LIBCPP_CONSTEXPR
-inline _LIBCPP_HIDE_FROM_ABI float __libcpp_copysign(float __x, float __y) _NOEXCEPT {
- return __builtin_copysignf(__x, __y);
-}
-
-_LIBCPP_CONSTEXPR
-inline _LIBCPP_HIDE_FROM_ABI double __libcpp_copysign(double __x, double __y) _NOEXCEPT {
- return __builtin_copysign(__x, __y);
-}
-
-_LIBCPP_CONSTEXPR
-inline _LIBCPP_HIDE_FROM_ABI long double __libcpp_copysign(long double __x, long double __y) _NOEXCEPT {
- return __builtin_copysignl(__x, __y);
-}
-
-template <class _A1, class _A2>
-_LIBCPP_CONSTEXPR
-inline _LIBCPP_HIDE_FROM_ABI
-typename std::__enable_if_t
-<
- std::is_arithmetic<_A1>::value &&
- std::is_arithmetic<_A2>::value,
- std::__promote<_A1, _A2>
->::type
-__libcpp_copysign(_A1 __x, _A2 __y) _NOEXCEPT {
- typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::_IsSame<_A1, __result_type>::value &&
- std::_IsSame<_A2, __result_type>::value)), "");
- return __builtin_copysign((__result_type)__x, (__result_type)__y);
-}
-
inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
- return ::__libcpp_copysign(__x, __y);
+ return ::__builtin_copysignf(__x, __y);
}
inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
- return ::__libcpp_copysign(__x, __y);
+ return ::__builtin_copysignl(__x, __y);
}
template <class _A1, class _A2>
@@ -1091,7 +1060,7 @@
std::__promote<_A1, _A2>
>::type
copysign(_A1 __x, _A2 __y) _NOEXCEPT {
- return ::__libcpp_copysign(__x, __y);
+ return ::__builtin_copysign(__x, __y);
}
// erf