summaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/complex
diff options
context:
space:
mode:
authormikhnenko <[email protected]>2024-01-26 10:38:46 +0300
committermikhnenko <[email protected]>2024-01-26 11:13:08 +0300
commit885b105cca4721eee2ee14d6b83d856dac3739ef (patch)
treec40b876bba01bcb469aadd981ef6d9dcbbbd589d /contrib/libs/cxxsupp/libcxx/include/complex
parent15e6154017194456fd8a7a76513e14aa4ae5f5d1 (diff)
Update libcxx to 02 June 2023 185b81e034ba60081023b6e59504dfffb560f3e3 (llvmorg-16.0.5)
:warning: Для всех проектов и мимо проходящим коллегам :warning: Если по каким-то причинам ваши тесты подломались, пожалуйста, переканонизируйте их сами. По статистике там просто поменялся порядок в канонизации. Если изменения действительно серьезные -- приходите в [DEVTOOLSSUPPORT](https://st.yandex-team.ru/createTicket?queue=DEVTOOLSSUPPORT) / пишите в телеграм / призывайте в тикеты, будем разбираться. ``` Changes: [libc++] Don't try to provide source_location on AppleClang 1403 [release/16.x][libc++] Revert the bitset sort optimization [libc++] Avoid ODR violations in __exception_guard [libc++][ranges] Fix incorrect integer typedef in `elements_view` test. [libc++][format] Fix a missing include in tests. [libc++][format] Fixes invalid usage of m type. [libc++][format] Fix floating point formatting. [libc++] Fix ranges::binary_search() returning true for cases where the element is not in the range [libc++] Temporarily not use compiler intrinsics for some type traits in Objective-C++ mode. [libc++][ranges] move all range iterators back in class [libcxx][ranges] revert join_view::iterator and sentinel to be in-class [libc++] Add FTM for views::as_rvalue [libc++] Fix bug in allocate_shared_for_overwrite [libc++] fix `shared_ptr`'s incorrect constraints [libc++] In tests, use `abort` to terminate upon an error. [libc++] Guard the fix to CityHash behind ABI v2 [libc++][format] Fixes constexpr validation. [libc++] Remove use of internal glibc macros to determine if c8rtomb() and mbrtoc8() are present. [libc++] Fixes the Clang modular build. [libc++][ranges] Temporarily mark `ranges::join_view` as experimental. libcxx: Don't apply ABI tags to extern "C" fns [libc++] Introduce a compile-time mechanism to override __libcpp_verbose_abort [libc++][format] Fixes usage of contiguous ranges. [libc++][doc] Updates format status. [libc++][ranges] implement `std::ranges::split_view` [libc++] implement P1020R1 P1973R1 make_unique[shared]_for_overwrite [libc++] Improve binary size when using __transaction [libc++] Rename take_while_view::__sentinel to __take_while_view_sentinel [libc++] Granularize <type_traits> includes in <bit>, <numbers> and <coroutine> [libc++] Implement P1413R3 (Deprecate std::aligned_storage and std::aligned_union) [libc++] Add FreeBSD XFAILs in preparation for CI [libc++] add FreeBSD atomic wait support [libc++][format] range-default-formatter for set. [libc++] Move iota_view::iterator and sentinel out of iota_view [libc++] Enable clang-tidy from the buildkite pipeline instead of hard-coding it in run-buildbot [libc++] Enable segmented iterator optimizations for join_view::iterator [libc++] Mark LWG3349 as complete [libc++] Remove old CI configurations and update the supported compiler versions [libc++] Implement P2446R2 (views::as_rvalue) [libc++][format] range-default-formatter for map [libc++][format] Adds formatter std::vector<bool>. [libc++][format] Adds container adaptor formatters. [libc++][format] Implements range_formatter [libc++][format] Adds new test macros. [libc++][ranges] Remove a leftover include version control markers in Cxx20Papers.csv [libc++][ranges] Mark completed Ranges papers and issues as done, bump version macro [libc++] Add ALLOW_RETRIES to a few flaky tests [SystemZ][z/OS] Fix cityhash lit for EBCDIC [libc++] Mark std::pmr virtual functions as _LIBCPP_HIDE_FROM_ABI_VIRTUAL [libc++] Remove <type_traits> includes from <atomic> and <ratio> [libcxx] Add missing includes [libc++] allow redefined macro in non_trivial_copy_move_ABI test [libc++][ranges] implement `std::views::elements_view` [libc++] Add [[clang::lifetimebound]] attribute to std::forward and friends Reapply "[libc++][ranges]Refactor `copy{,_backward}` and `move{,_backward}`" [libc++] Add clang-tidy to the list of possible substitutions for %{clang-tidy} [libc++] Add missing includes in move_iterator.h [libc++] Make pmr::monotonic_buffer_resource bump down [libc++] Add [[nodiscard]] extensions in <math.h> [libc++] Fix ranges::uninitialized_move{, _n} for move-only types [libc++][ranges] Fix incorrect integer type in `view_interface` tests. [libc++] Hold mutex lock while notify_all is called at notify_all_at_thread_exit [Libcxx] Add <source_location> header. [libc++] Rename transform_view::{__iterator, __sentinel} to __transform_view_{iterator, sentinel} [libc++] Add FreeBSD exceptions.nonew ABI list [libc++][format] Fixes escaping string literals. [libc++] Use _LIBCPP_HIDE_FROM_ABI_VIRTUAL instead of _LIBCPP_INLINE_VISIBILITY attribute on virtual function [libc++][test] Move `common_input_iterator` to `test_iterators.h` [libc++][utils] Remove unused import in `run.py` [libc++] Remove warning for `LIBCXX_SYSROOT`, `LIBCXX_TARGET_TRIPLE`, and `LIBCXX_GCC_TOOLCHAIN` [libc++] Fix aligned_alloc usage for Android [libc++] Use %{clang-query} when calling clang-query [libc++] Add missing include in __format/unicode.h [libc++] Remove HIDE_FROM_ABI from virtual functions [libc++] Fix transitive includes list for C++23 [libc++] Add _LIBCPP_HIDE_FROM_ABI to __constexpr_logb and __constexpr_scalbn [libc++] Granularize <bit> and remove <__bits> [libc++] [C++20] [P0415] Constexpr for std::complex. libc++: bring back the unsigned in the return type in wcstoull_l [libc++][CI] Improves clang-(tidy|query) selection. [libc++] Granularize <type_traits> includes in <iterator> [libc++] Implement constexpr {isfinite, isinf, isnan, isnormal} [libc++][chrono] Add calendar type formatters. [libc++] LWG3738 Validates a missing precondition. [libc++] LWG3745 noexcept for atomic_wait. [libc++] Granularize <type_traits> includes in <compare> std::sort: add BlockQuickSort partitioning algorithm for arithmetic types [libc++] Granularize <type_traits> includes in <utility> [libc++][format] Removes test redundancy. [libc++][format] Adds formatter for tuple and pair [libc++] Use aligned_alloc instead of posix_memalign for C++17 [libc++] Rename __tuple to __tuple_dir to avoid file collision [libc++] Add FreeBSD ABI list [libc++] Adds __cpp_lib_constexpr_algorithms to utility. [libc++] Granularize <type_traits> includes in <concepts [libc++][format] Renames __null_sentinel. Implementstd::ranges::view_interface::size returns a signed type [libc++] Implement P1169R4 (static operator()) [libc++] Implement `std::expected` P0323R12 [libc++][Android] Disable pbump2gig for Android [libc++][Android] Android/Bionic headers don't work with modules yet [libc++][math.h] Add double overloads [libc++] Move filter_view::iterator and sentinel out of filter_view [libc++] Implement P0339R6 (polymorphic_allocator<> as a vocabulary type) [libc++][format] Adds range-default-formatter. [libc++][Android] Rename user NS to User to avoid conflict with struct [libc++] Fix memory leaks when throwing inside std::vector constructors ```
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/complex')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/complex700
1 files changed, 387 insertions, 313 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/complex b/contrib/libs/cxxsupp/libcxx/include/complex
index 293ec3d439e..cac901af463 100644
--- a/contrib/libs/cxxsupp/libcxx/include/complex
+++ b/contrib/libs/cxxsupp/libcxx/include/complex
@@ -29,21 +29,21 @@ public:
T real() const; // constexpr in C++14
T imag() const; // constexpr in C++14
- void real(T);
- void imag(T);
-
- complex<T>& operator= (const T&);
- complex<T>& operator+=(const T&);
- complex<T>& operator-=(const T&);
- complex<T>& operator*=(const T&);
- complex<T>& operator/=(const T&);
-
- complex& operator=(const complex&);
- template<class X> complex<T>& operator= (const complex<X>&);
- template<class X> complex<T>& operator+=(const complex<X>&);
- template<class X> complex<T>& operator-=(const complex<X>&);
- template<class X> complex<T>& operator*=(const complex<X>&);
- template<class X> complex<T>& operator/=(const complex<X>&);
+ void real(T); // constexpr in C++20
+ void imag(T); // constexpr in C++20
+
+ complex<T>& operator= (const T&); // constexpr in C++20
+ complex<T>& operator+=(const T&); // constexpr in C++20
+ complex<T>& operator-=(const T&); // constexpr in C++20
+ complex<T>& operator*=(const T&); // constexpr in C++20
+ complex<T>& operator/=(const T&); // constexpr in C++20
+
+ complex& operator=(const complex&); // constexpr in C++20
+ template<class X> complex<T>& operator= (const complex<X>&); // constexpr in C++20
+ template<class X> complex<T>& operator+=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<T>& operator-=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<T>& operator*=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<T>& operator/=(const complex<X>&); // constexpr in C++20
};
template<>
@@ -57,22 +57,22 @@ public:
explicit constexpr complex(const complex<long double>&);
constexpr float real() const;
- void real(float);
+ void real(float); // constexpr in C++20
constexpr float imag() const;
- void imag(float);
-
- complex<float>& operator= (float);
- complex<float>& operator+=(float);
- complex<float>& operator-=(float);
- complex<float>& operator*=(float);
- complex<float>& operator/=(float);
-
- complex<float>& operator=(const complex<float>&);
- template<class X> complex<float>& operator= (const complex<X>&);
- template<class X> complex<float>& operator+=(const complex<X>&);
- template<class X> complex<float>& operator-=(const complex<X>&);
- template<class X> complex<float>& operator*=(const complex<X>&);
- template<class X> complex<float>& operator/=(const complex<X>&);
+ void imag(float); // constexpr in C++20
+
+ complex<float>& operator= (float); // constexpr in C++20
+ complex<float>& operator+=(float); // constexpr in C++20
+ complex<float>& operator-=(float); // constexpr in C++20
+ complex<float>& operator*=(float); // constexpr in C++20
+ complex<float>& operator/=(float); // constexpr in C++20
+
+ complex<float>& operator=(const complex<float>&); // constexpr in C++20
+ template<class X> complex<float>& operator= (const complex<X>&); // constexpr in C++20
+ template<class X> complex<float>& operator+=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<float>& operator-=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<float>& operator*=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<float>& operator/=(const complex<X>&); // constexpr in C++20
};
template<>
@@ -86,22 +86,22 @@ public:
explicit constexpr complex(const complex<long double>&);
constexpr double real() const;
- void real(double);
+ void real(double); // constexpr in C++20
constexpr double imag() const;
- void imag(double);
-
- complex<double>& operator= (double);
- complex<double>& operator+=(double);
- complex<double>& operator-=(double);
- complex<double>& operator*=(double);
- complex<double>& operator/=(double);
- complex<double>& operator=(const complex<double>&);
-
- template<class X> complex<double>& operator= (const complex<X>&);
- template<class X> complex<double>& operator+=(const complex<X>&);
- template<class X> complex<double>& operator-=(const complex<X>&);
- template<class X> complex<double>& operator*=(const complex<X>&);
- template<class X> complex<double>& operator/=(const complex<X>&);
+ void imag(double); // constexpr in C++20
+
+ complex<double>& operator= (double); // constexpr in C++20
+ complex<double>& operator+=(double); // constexpr in C++20
+ complex<double>& operator-=(double); // constexpr in C++20
+ complex<double>& operator*=(double); // constexpr in C++20
+ complex<double>& operator/=(double); // constexpr in C++20
+ complex<double>& operator=(const complex<double>&); // constexpr in C++20
+
+ template<class X> complex<double>& operator= (const complex<X>&); // constexpr in C++20
+ template<class X> complex<double>& operator+=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<double>& operator-=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<double>& operator*=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<double>& operator/=(const complex<X>&); // constexpr in C++20
};
template<>
@@ -115,39 +115,39 @@ public:
constexpr complex(const complex<double>&);
constexpr long double real() const;
- void real(long double);
+ void real(long double); // constexpr in C++20
constexpr long double imag() const;
- void imag(long double);
-
- complex<long double>& operator=(const complex<long double>&);
- complex<long double>& operator= (long double);
- complex<long double>& operator+=(long double);
- complex<long double>& operator-=(long double);
- complex<long double>& operator*=(long double);
- complex<long double>& operator/=(long double);
-
- template<class X> complex<long double>& operator= (const complex<X>&);
- template<class X> complex<long double>& operator+=(const complex<X>&);
- template<class X> complex<long double>& operator-=(const complex<X>&);
- template<class X> complex<long double>& operator*=(const complex<X>&);
- template<class X> complex<long double>& operator/=(const complex<X>&);
+ void imag(long double); // constexpr in C++20
+
+ complex<long double>& operator=(const complex<long double>&); // constexpr in C++20
+ complex<long double>& operator= (long double); // constexpr in C++20
+ complex<long double>& operator+=(long double); // constexpr in C++20
+ complex<long double>& operator-=(long double); // constexpr in C++20
+ complex<long double>& operator*=(long double); // constexpr in C++20
+ complex<long double>& operator/=(long double); // constexpr in C++20
+
+ template<class X> complex<long double>& operator= (const complex<X>&); // constexpr in C++20
+ template<class X> complex<long double>& operator+=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<long double>& operator-=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<long double>& operator*=(const complex<X>&); // constexpr in C++20
+ template<class X> complex<long double>& operator/=(const complex<X>&); // constexpr in C++20
};
// 26.3.6 operators:
-template<class T> complex<T> operator+(const complex<T>&, const complex<T>&);
-template<class T> complex<T> operator+(const complex<T>&, const T&);
-template<class T> complex<T> operator+(const T&, const complex<T>&);
-template<class T> complex<T> operator-(const complex<T>&, const complex<T>&);
-template<class T> complex<T> operator-(const complex<T>&, const T&);
-template<class T> complex<T> operator-(const T&, const complex<T>&);
-template<class T> complex<T> operator*(const complex<T>&, const complex<T>&);
-template<class T> complex<T> operator*(const complex<T>&, const T&);
-template<class T> complex<T> operator*(const T&, const complex<T>&);
-template<class T> complex<T> operator/(const complex<T>&, const complex<T>&);
-template<class T> complex<T> operator/(const complex<T>&, const T&);
-template<class T> complex<T> operator/(const T&, const complex<T>&);
-template<class T> complex<T> operator+(const complex<T>&);
-template<class T> complex<T> operator-(const complex<T>&);
+template<class T> complex<T> operator+(const complex<T>&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator+(const complex<T>&, const T&); // constexpr in C++20
+template<class T> complex<T> operator+(const T&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator-(const complex<T>&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator-(const complex<T>&, const T&); // constexpr in C++20
+template<class T> complex<T> operator-(const T&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator*(const complex<T>&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator*(const complex<T>&, const T&); // constexpr in C++20
+template<class T> complex<T> operator*(const T&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator/(const complex<T>&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator/(const complex<T>&, const T&); // constexpr in C++20
+template<class T> complex<T> operator/(const T&, const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator+(const complex<T>&); // constexpr in C++20
+template<class T> complex<T> operator-(const complex<T>&); // constexpr in C++20
template<class T> bool operator==(const complex<T>&, const complex<T>&); // constexpr in C++14
template<class T> bool operator==(const complex<T>&, const T&); // constexpr in C++14
template<class T> bool operator==(const T&, const complex<T>&); // constexpr in C++14
@@ -184,17 +184,17 @@ template<class T> T arg(const complex<T>&);
template<Integral T> double arg(T);
float arg(float);
-template<class T> T norm(const complex<T>&);
- long double norm(long double);
- double norm(double);
-template<Integral T> double norm(T);
- float norm(float);
+template<class T> T norm(const complex<T>&); // constexpr in C++20
+ long double norm(long double); // constexpr in C++20
+ double norm(double); // constexpr in C++20
+template<Integral T> double norm(T); // constexpr in C++20
+ float norm(float); // constexpr in C++20
-template<class T> complex<T> conj(const complex<T>&);
- complex<long double> conj(long double);
- complex<double> conj(double);
-template<Integral T> complex<double> conj(T);
- complex<float> conj(float);
+template<class T> complex<T> conj(const complex<T>&); // constexpr in C++20
+ complex<long double> conj(long double); // constexpr in C++20
+ complex<double> conj(double); // constexpr in C++20
+template<Integral T> complex<double> conj(T); // constexpr in C++20
+ complex<float> conj(float); // constexpr in C++20
template<class T> complex<T> proj(const complex<T>&);
complex<long double> proj(long double);
@@ -251,8 +251,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _Tp> class _LIBCPP_TEMPLATE_VIS complex;
-template<class _Tp> _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
-template<class _Tp> _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
+template<class _Tp> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
+template<class _Tp> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
template<class _Tp>
class _LIBCPP_TEMPLATE_VIS complex
@@ -273,40 +273,40 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 value_type real() const {return __re_;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 value_type imag() const {return __im_;}
- _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
- _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) {__im_ = __im;}
- _LIBCPP_INLINE_VISIBILITY complex& operator= (const value_type& __re)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (const value_type& __re)
{__re_ = __re; __im_ = value_type(); return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator+=(const value_type& __re) {__re_ += __re; return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator-=(const value_type& __re) {__re_ -= __re; return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator*=(const value_type& __re) {__re_ *= __re; __im_ *= __re; return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator/=(const value_type& __re) {__re_ /= __re; __im_ /= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const value_type& __re) {__re_ += __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const value_type& __re) {__re_ -= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const value_type& __re) {__re_ *= __re; __im_ *= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const value_type& __re) {__re_ /= __re; __im_ /= __re; return *this;}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (const complex<_Xp>& __c)
{
__re_ = __c.real();
__im_ = __c.imag();
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const complex<_Xp>& __c)
{
__re_ += __c.real();
__im_ += __c.imag();
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const complex<_Xp>& __c)
{
__re_ -= __c.real();
__im_ -= __c.imag();
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const complex<_Xp>& __c)
{
*this = *this * complex(__c.real(), __c.imag());
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c)
{
*this = *this / complex(__c.real(), __c.imag());
return *this;
@@ -334,40 +334,40 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float real() const {return __re_;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float imag() const {return __im_;}
- _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
- _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) {__im_ = __im;}
- _LIBCPP_INLINE_VISIBILITY complex& operator= (float __re)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (float __re)
{__re_ = __re; __im_ = value_type(); return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator+=(float __re) {__re_ += __re; return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator-=(float __re) {__re_ -= __re; return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator*=(float __re) {__re_ *= __re; __im_ *= __re; return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator/=(float __re) {__re_ /= __re; __im_ /= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(float __re) {__re_ += __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(float __re) {__re_ -= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(float __re) {__re_ *= __re; __im_ *= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(float __re) {__re_ /= __re; __im_ /= __re; return *this;}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (const complex<_Xp>& __c)
{
__re_ = __c.real();
__im_ = __c.imag();
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const complex<_Xp>& __c)
{
__re_ += __c.real();
__im_ += __c.imag();
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const complex<_Xp>& __c)
{
__re_ -= __c.real();
__im_ -= __c.imag();
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const complex<_Xp>& __c)
{
*this = *this * complex(__c.real(), __c.imag());
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c)
{
*this = *this / complex(__c.real(), __c.imag());
return *this;
@@ -392,40 +392,40 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double real() const {return __re_;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double imag() const {return __im_;}
- _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
- _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) {__im_ = __im;}
- _LIBCPP_INLINE_VISIBILITY complex& operator= (double __re)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (double __re)
{__re_ = __re; __im_ = value_type(); return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator+=(double __re) {__re_ += __re; return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator-=(double __re) {__re_ -= __re; return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator*=(double __re) {__re_ *= __re; __im_ *= __re; return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator/=(double __re) {__re_ /= __re; __im_ /= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(double __re) {__re_ += __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(double __re) {__re_ -= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(double __re) {__re_ *= __re; __im_ *= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(double __re) {__re_ /= __re; __im_ /= __re; return *this;}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (const complex<_Xp>& __c)
{
__re_ = __c.real();
__im_ = __c.imag();
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const complex<_Xp>& __c)
{
__re_ += __c.real();
__im_ += __c.imag();
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const complex<_Xp>& __c)
{
__re_ -= __c.real();
__im_ -= __c.imag();
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const complex<_Xp>& __c)
{
*this = *this * complex(__c.real(), __c.imag());
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c)
{
*this = *this / complex(__c.real(), __c.imag());
return *this;
@@ -450,40 +450,40 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double real() const {return __re_;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double imag() const {return __im_;}
- _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
- _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) {__im_ = __im;}
- _LIBCPP_INLINE_VISIBILITY complex& operator= (long double __re)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (long double __re)
{__re_ = __re; __im_ = value_type(); return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator+=(long double __re) {__re_ += __re; return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator-=(long double __re) {__re_ -= __re; return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator*=(long double __re) {__re_ *= __re; __im_ *= __re; return *this;}
- _LIBCPP_INLINE_VISIBILITY complex& operator/=(long double __re) {__re_ /= __re; __im_ /= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(long double __re) {__re_ += __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(long double __re) {__re_ -= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(long double __re) {__re_ *= __re; __im_ *= __re; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(long double __re) {__re_ /= __re; __im_ /= __re; return *this;}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (const complex<_Xp>& __c)
{
__re_ = __c.real();
__im_ = __c.imag();
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const complex<_Xp>& __c)
{
__re_ += __c.real();
__im_ += __c.imag();
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const complex<_Xp>& __c)
{
__re_ -= __c.real();
__im_ -= __c.imag();
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const complex<_Xp>& __c)
{
*this = *this * complex(__c.real(), __c.imag());
return *this;
}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c)
{
*this = *this / complex(__c.real(), __c.imag());
return *this;
@@ -523,7 +523,7 @@ complex<long double>::complex(const complex<double>& __c)
// 26.3.6 operators:
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
{
@@ -533,7 +533,7 @@ operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator+(const complex<_Tp>& __x, const _Tp& __y)
{
@@ -543,7 +543,7 @@ operator+(const complex<_Tp>& __x, const _Tp& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator+(const _Tp& __x, const complex<_Tp>& __y)
{
@@ -553,7 +553,7 @@ operator+(const _Tp& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
{
@@ -563,7 +563,7 @@ operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator-(const complex<_Tp>& __x, const _Tp& __y)
{
@@ -573,7 +573,7 @@ operator-(const complex<_Tp>& __x, const _Tp& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator-(const _Tp& __x, const complex<_Tp>& __y)
{
@@ -583,53 +583,86 @@ operator-(const _Tp& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-_LIBCPP_HIDE_FROM_ABI complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
{
_Tp __a = __z.real();
_Tp __b = __z.imag();
_Tp __c = __w.real();
_Tp __d = __w.imag();
+
+ // Avoid floating point operations that are invalid during constant evaluation
+ if (__libcpp_is_constant_evaluated()) {
+ bool __z_zero = __a == _Tp(0) && __b == _Tp(0);
+ bool __w_zero = __c == _Tp(0) && __d == _Tp(0);
+ bool __z_inf = std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b);
+ bool __w_inf = std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d);
+ bool __z_nan = !__z_inf && (
+ (std::__constexpr_isnan(__a) && std::__constexpr_isnan(__b))
+ || (std::__constexpr_isnan(__a) && __b == _Tp(0))
+ || (__a == _Tp(0) && std::__constexpr_isnan(__b))
+ );
+ bool __w_nan = !__w_inf && (
+ (std::__constexpr_isnan(__c) && std::__constexpr_isnan(__d))
+ || (std::__constexpr_isnan(__c) && __d == _Tp(0))
+ || (__c == _Tp(0) && std::__constexpr_isnan(__d))
+ );
+ if (__z_nan || __w_nan) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
+ }
+ if (__z_inf || __w_inf) {
+ if (__z_zero || __w_zero) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
+ }
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
+ }
+ bool __z_nonzero_nan = !__z_inf && !__z_nan && (std::__constexpr_isnan(__a) || std::__constexpr_isnan(__b));
+ bool __w_nonzero_nan = !__w_inf && !__w_nan && (std::__constexpr_isnan(__c) || std::__constexpr_isnan(__d));
+ if (__z_nonzero_nan || __w_nonzero_nan) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
+ }
+ }
+
_Tp __ac = __a * __c;
_Tp __bd = __b * __d;
_Tp __ad = __a * __d;
_Tp __bc = __b * __c;
_Tp __x = __ac - __bd;
_Tp __y = __ad + __bc;
- if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))
+ if (std::__constexpr_isnan(__x) && std::__constexpr_isnan(__y))
{
bool __recalc = false;
- if (__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b))
+ if (std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b))
{
- __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
- __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
- if (__libcpp_isnan_or_builtin(__c))
- __c = copysign(_Tp(0), __c);
- if (__libcpp_isnan_or_builtin(__d))
- __d = copysign(_Tp(0), __d);
+ __a = std::__constexpr_copysign(std::__constexpr_isinf(__a) ? _Tp(1) : _Tp(0), __a);
+ __b = std::__constexpr_copysign(std::__constexpr_isinf(__b) ? _Tp(1) : _Tp(0), __b);
+ if (std::__constexpr_isnan(__c))
+ __c = std::__constexpr_copysign(_Tp(0), __c);
+ if (std::__constexpr_isnan(__d))
+ __d = std::__constexpr_copysign(_Tp(0), __d);
__recalc = true;
}
- if (__libcpp_isinf_or_builtin(__c) || __libcpp_isinf_or_builtin(__d))
+ if (std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d))
{
- __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);
- __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
- if (__libcpp_isnan_or_builtin(__a))
- __a = copysign(_Tp(0), __a);
- if (__libcpp_isnan_or_builtin(__b))
- __b = copysign(_Tp(0), __b);
+ __c = std::__constexpr_copysign(std::__constexpr_isinf(__c) ? _Tp(1) : _Tp(0), __c);
+ __d = std::__constexpr_copysign(std::__constexpr_isinf(__d) ? _Tp(1) : _Tp(0), __d);
+ if (std::__constexpr_isnan(__a))
+ __a = std::__constexpr_copysign(_Tp(0), __a);
+ if (std::__constexpr_isnan(__b))
+ __b = std::__constexpr_copysign(_Tp(0), __b);
__recalc = true;
}
- if (!__recalc && (__libcpp_isinf_or_builtin(__ac) || __libcpp_isinf_or_builtin(__bd) ||
- __libcpp_isinf_or_builtin(__ad) || __libcpp_isinf_or_builtin(__bc)))
+ if (!__recalc && (std::__constexpr_isinf(__ac) || std::__constexpr_isinf(__bd) ||
+ std::__constexpr_isinf(__ad) || std::__constexpr_isinf(__bc)))
{
- if (__libcpp_isnan_or_builtin(__a))
- __a = copysign(_Tp(0), __a);
- if (__libcpp_isnan_or_builtin(__b))
- __b = copysign(_Tp(0), __b);
- if (__libcpp_isnan_or_builtin(__c))
- __c = copysign(_Tp(0), __c);
- if (__libcpp_isnan_or_builtin(__d))
- __d = copysign(_Tp(0), __d);
+ if (std::__constexpr_isnan(__a))
+ __a = std::__constexpr_copysign(_Tp(0), __a);
+ if (std::__constexpr_isnan(__b))
+ __b = std::__constexpr_copysign(_Tp(0), __b);
+ if (std::__constexpr_isnan(__c))
+ __c = std::__constexpr_copysign(_Tp(0), __c);
+ if (std::__constexpr_isnan(__d))
+ __d = std::__constexpr_copysign(_Tp(0), __d);
__recalc = true;
}
if (__recalc)
@@ -642,7 +675,7 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator*(const complex<_Tp>& __x, const _Tp& __y)
{
@@ -652,7 +685,7 @@ operator*(const complex<_Tp>& __x, const _Tp& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator*(const _Tp& __x, const complex<_Tp>& __y)
{
@@ -662,7 +695,7 @@ operator*(const _Tp& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-_LIBCPP_HIDE_FROM_ABI complex<_Tp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
{
int __ilogbw = 0;
@@ -670,34 +703,74 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __b = __z.imag();
_Tp __c = __w.real();
_Tp __d = __w.imag();
- _Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));
- if (__libcpp_isfinite_or_builtin(__logbw))
+ _Tp __logbw = std::__constexpr_logb(std::__constexpr_fmax(std::__constexpr_fabs(__c), std::__constexpr_fabs(__d)));
+ if (std::__constexpr_isfinite(__logbw))
{
__ilogbw = static_cast<int>(__logbw);
- __c = scalbn(__c, -__ilogbw);
- __d = scalbn(__d, -__ilogbw);
+ __c = std::__constexpr_scalbn(__c, -__ilogbw);
+ __d = std::__constexpr_scalbn(__d, -__ilogbw);
}
+
+ // Avoid floating point operations that are invalid during constant evaluation
+ if (__libcpp_is_constant_evaluated()) {
+ bool __z_zero = __a == _Tp(0) && __b == _Tp(0);
+ bool __w_zero = __c == _Tp(0) && __d == _Tp(0);
+ bool __z_inf = std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b);
+ bool __w_inf = std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d);
+ bool __z_nan = !__z_inf && (
+ (std::__constexpr_isnan(__a) && std::__constexpr_isnan(__b))
+ || (std::__constexpr_isnan(__a) && __b == _Tp(0))
+ || (__a == _Tp(0) && std::__constexpr_isnan(__b))
+ );
+ bool __w_nan = !__w_inf && (
+ (std::__constexpr_isnan(__c) && std::__constexpr_isnan(__d))
+ || (std::__constexpr_isnan(__c) && __d == _Tp(0))
+ || (__c == _Tp(0) && std::__constexpr_isnan(__d))
+ );
+ if ((__z_nan || __w_nan) || (__z_inf && __w_inf)) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
+ }
+ bool __z_nonzero_nan = !__z_inf && !__z_nan && (std::__constexpr_isnan(__a) || std::__constexpr_isnan(__b));
+ bool __w_nonzero_nan = !__w_inf && !__w_nan && (std::__constexpr_isnan(__c) || std::__constexpr_isnan(__d));
+ if (__z_nonzero_nan || __w_nonzero_nan) {
+ if (__w_zero) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
+ }
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
+ }
+ if (__w_inf) {
+ return complex<_Tp>(_Tp(0), _Tp(0));
+ }
+ if (__z_inf) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
+ }
+ if (__w_zero) {
+ if (__z_zero) {
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
+ }
+ return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
+ }
+ }
+
_Tp __denom = __c * __c + __d * __d;
- _Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
- _Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
- if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))
+ _Tp __x = std::__constexpr_scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
+ _Tp __y = std::__constexpr_scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
+ if (std::__constexpr_isnan(__x) && std::__constexpr_isnan(__y))
{
- if ((__denom == _Tp(0)) && (!__libcpp_isnan_or_builtin(__a) || !__libcpp_isnan_or_builtin(__b)))
- {
- __x = copysign(_Tp(INFINITY), __c) * __a;
- __y = copysign(_Tp(INFINITY), __c) * __b;
- }
- else if ((__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b)) && __libcpp_isfinite_or_builtin(__c) && __libcpp_isfinite_or_builtin(__d))
+ if ((__denom == _Tp(0)) && (!std::__constexpr_isnan(__a) || !std::__constexpr_isnan(__b)))
{
- __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
- __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
+ __x = std::__constexpr_copysign(_Tp(INFINITY), __c) * __a;
+ __y = std::__constexpr_copysign(_Tp(INFINITY), __c) * __b;
+ } else if ((std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b)) && std::__constexpr_isfinite(__c) &&
+ std::__constexpr_isfinite(__d)) {
+ __a = std::__constexpr_copysign(std::__constexpr_isinf(__a) ? _Tp(1) : _Tp(0), __a);
+ __b = std::__constexpr_copysign(std::__constexpr_isinf(__b) ? _Tp(1) : _Tp(0), __b);
__x = _Tp(INFINITY) * (__a * __c + __b * __d);
__y = _Tp(INFINITY) * (__b * __c - __a * __d);
- }
- else if (__libcpp_isinf_or_builtin(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite_or_builtin(__a) && __libcpp_isfinite_or_builtin(__b))
- {
- __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);
- __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
+ } else if (std::__constexpr_isinf(__logbw) && __logbw > _Tp(0) && std::__constexpr_isfinite(__a) &&
+ std::__constexpr_isfinite(__b)) {
+ __c = std::__constexpr_copysign(std::__constexpr_isinf(__c) ? _Tp(1) : _Tp(0), __c);
+ __d = std::__constexpr_copysign(std::__constexpr_isinf(__d) ? _Tp(1) : _Tp(0), __d);
__x = _Tp(0) * (__a * __c + __b * __d);
__y = _Tp(0) * (__b * __c - __a * __d);
}
@@ -706,7 +779,7 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator/(const complex<_Tp>& __x, const _Tp& __y)
{
@@ -714,7 +787,7 @@ operator/(const complex<_Tp>& __x, const _Tp& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator/(const _Tp& __x, const complex<_Tp>& __y)
{
@@ -724,7 +797,7 @@ operator/(const _Tp& __x, const complex<_Tp>& __y)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator+(const complex<_Tp>& __x)
{
@@ -732,7 +805,7 @@ operator+(const complex<_Tp>& __x)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
operator-(const complex<_Tp>& __x)
{
@@ -853,7 +926,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_Tp
abs(const complex<_Tp>& __c)
{
- return hypot(__c.real(), __c.imag());
+ return std::hypot(__c.real(), __c.imag());
}
// arg
@@ -863,7 +936,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_Tp
arg(const complex<_Tp>& __c)
{
- return atan2(__c.imag(), __c.real());
+ return std::atan2(__c.imag(), __c.real());
}
template <class _Tp>
@@ -874,7 +947,7 @@ typename enable_if<
>::type
arg(_Tp __re)
{
- return atan2l(0.L, __re);
+ return std::atan2l(0.L, __re);
}
template<class _Tp>
@@ -886,7 +959,7 @@ typename enable_if
>::type
arg(_Tp __re)
{
- return atan2(0., __re);
+ return std::atan2(0., __re);
}
template <class _Tp>
@@ -897,25 +970,25 @@ typename enable_if<
>::type
arg(_Tp __re)
{
- return atan2f(0.F, __re);
+ return std::atan2f(0.F, __re);
}
// norm
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_Tp
norm(const complex<_Tp>& __c)
{
- if (__libcpp_isinf_or_builtin(__c.real()))
- return abs(__c.real());
- if (__libcpp_isinf_or_builtin(__c.imag()))
- return abs(__c.imag());
+ if (std::__constexpr_isinf(__c.real()))
+ return std::abs(__c.real());
+ if (std::__constexpr_isinf(__c.imag()))
+ return std::abs(__c.imag());
return __c.real() * __c.real() + __c.imag() * __c.imag();
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __libcpp_complex_overload_traits<_Tp>::_ValueType
norm(_Tp __re)
{
@@ -926,7 +999,7 @@ norm(_Tp __re)
// conj
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
complex<_Tp>
conj(const complex<_Tp>& __c)
{
@@ -934,7 +1007,7 @@ conj(const complex<_Tp>& __c)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
conj(_Tp __re)
{
@@ -952,8 +1025,8 @@ complex<_Tp>
proj(const complex<_Tp>& __c)
{
complex<_Tp> __r = __c;
- if (__libcpp_isinf_or_builtin(__c.real()) || __libcpp_isinf_or_builtin(__c.imag()))
- __r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));
+ if (std::__constexpr_isinf(__c.real()) || std::__constexpr_isinf(__c.imag()))
+ __r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag()));
return __r;
}
@@ -966,8 +1039,8 @@ typename enable_if
>::type
proj(_Tp __re)
{
- if (__libcpp_isinf_or_builtin(__re))
- __re = abs(__re);
+ if (std::__constexpr_isinf(__re))
+ __re = std::abs(__re);
return complex<_Tp>(__re);
}
@@ -990,25 +1063,25 @@ template<class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp>
polar(const _Tp& __rho, const _Tp& __theta = _Tp())
{
- if (__libcpp_isnan_or_builtin(__rho) || signbit(__rho))
+ if (std::__constexpr_isnan(__rho) || std::signbit(__rho))
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
- if (__libcpp_isnan_or_builtin(__theta))
+ if (std::__constexpr_isnan(__theta))
{
- if (__libcpp_isinf_or_builtin(__rho))
+ if (std::__constexpr_isinf(__rho))
return complex<_Tp>(__rho, __theta);
return complex<_Tp>(__theta, __theta);
}
- if (__libcpp_isinf_or_builtin(__theta))
+ if (std::__constexpr_isinf(__theta))
{
- if (__libcpp_isinf_or_builtin(__rho))
+ if (std::__constexpr_isinf(__rho))
return complex<_Tp>(__rho, _Tp(NAN));
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
}
- _Tp __x = __rho * cos(__theta);
- if (__libcpp_isnan_or_builtin(__x))
+ _Tp __x = __rho * std::cos(__theta);
+ if (std::__constexpr_isnan(__x))
__x = 0;
- _Tp __y = __rho * sin(__theta);
- if (__libcpp_isnan_or_builtin(__y))
+ _Tp __y = __rho * std::sin(__theta);
+ if (std::__constexpr_isnan(__y))
__y = 0;
return complex<_Tp>(__x, __y);
}
@@ -1020,7 +1093,7 @@ inline _LIBCPP_INLINE_VISIBILITY
complex<_Tp>
log(const complex<_Tp>& __x)
{
- return complex<_Tp>(log(abs(__x)), arg(__x));
+ return complex<_Tp>(std::log(std::abs(__x)), std::arg(__x));
}
// log10
@@ -1030,7 +1103,7 @@ inline _LIBCPP_INLINE_VISIBILITY
complex<_Tp>
log10(const complex<_Tp>& __x)
{
- return log(__x) / log(_Tp(10));
+ return std::log(__x) / std::log(_Tp(10));
}
// sqrt
@@ -1039,15 +1112,15 @@ template<class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp>
sqrt(const complex<_Tp>& __x)
{
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.imag()))
return complex<_Tp>(_Tp(INFINITY), __x.imag());
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__x.real()))
{
if (__x.real() > _Tp(0))
- return complex<_Tp>(__x.real(), __libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
- return complex<_Tp>(__libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
+ return complex<_Tp>(__x.real(), std::__constexpr_isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag()));
+ return complex<_Tp>(std::__constexpr_isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag()));
}
- return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
+ return std::polar(std::sqrt(std::abs(__x)), std::arg(__x) / _Tp(2));
}
// exp
@@ -1058,24 +1131,24 @@ exp(const complex<_Tp>& __x)
{
_Tp __i = __x.imag();
if (__i == 0) {
- return complex<_Tp>(exp(__x.real()), copysign(_Tp(0), __x.imag()));
+ return complex<_Tp>(std::exp(__x.real()), std::copysign(_Tp(0), __x.imag()));
}
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__x.real()))
{
if (__x.real() < _Tp(0))
{
- if (!__libcpp_isfinite_or_builtin(__i))
+ if (!std::__constexpr_isfinite(__i))
__i = _Tp(1);
}
- else if (__i == 0 || !__libcpp_isfinite_or_builtin(__i))
+ else if (__i == 0 || !std::__constexpr_isfinite(__i))
{
- if (__libcpp_isinf_or_builtin(__i))
+ if (std::__constexpr_isinf(__i))
__i = _Tp(NAN);
return complex<_Tp>(__x.real(), __i);
}
}
- _Tp __e = exp(__x.real());
- return complex<_Tp>(__e * cos(__i), __e * sin(__i));
+ _Tp __e = std::exp(__x.real());
+ return complex<_Tp>(__e * std::cos(__i), __e * std::sin(__i));
}
// pow
@@ -1085,7 +1158,7 @@ inline _LIBCPP_INLINE_VISIBILITY
complex<_Tp>
pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
{
- return exp(__y * log(__x));
+ return std::exp(__y * std::log(__x));
}
template<class _Tp, class _Up>
@@ -1141,26 +1214,26 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp>
asinh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__x.real()))
{
- if (__libcpp_isnan_or_builtin(__x.imag()))
+ if (std::__constexpr_isnan(__x.imag()))
return __x;
- if (__libcpp_isinf_or_builtin(__x.imag()))
- return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
- return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
+ if (std::__constexpr_isinf(__x.imag()))
+ return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
+ return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
}
- if (__libcpp_isnan_or_builtin(__x.real()))
+ if (std::__constexpr_isnan(__x.real()))
{
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real());
if (__x.imag() == 0)
return __x;
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf_or_builtin(__x.imag()))
- return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
- complex<_Tp> __z = log(__x + sqrt(__sqr(__x) + _Tp(1)));
- return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
+ if (std::__constexpr_isinf(__x.imag()))
+ return complex<_Tp>(std::copysign(__x.imag(), __x.real()), std::copysign(__pi/_Tp(2), __x.imag()));
+ complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) + _Tp(1)));
+ return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));
}
// acosh
@@ -1170,31 +1243,31 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp>
acosh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__x.real()))
{
- if (__libcpp_isnan_or_builtin(__x.imag()))
- return complex<_Tp>(abs(__x.real()), __x.imag());
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isnan(__x.imag()))
+ return complex<_Tp>(std::abs(__x.real()), __x.imag());
+ if (std::__constexpr_isinf(__x.imag()))
{
if (__x.real() > 0)
- return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
+ return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
else
- return complex<_Tp>(-__x.real(), copysign(__pi * _Tp(0.75), __x.imag()));
+ return complex<_Tp>(-__x.real(), std::copysign(__pi * _Tp(0.75), __x.imag()));
}
if (__x.real() < 0)
- return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag()));
- return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
+ return complex<_Tp>(-__x.real(), std::copysign(__pi, __x.imag()));
+ return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
}
- if (__libcpp_isnan_or_builtin(__x.real()))
+ if (std::__constexpr_isnan(__x.real()))
{
- if (__libcpp_isinf_or_builtin(__x.imag()))
- return complex<_Tp>(abs(__x.imag()), __x.real());
+ if (std::__constexpr_isinf(__x.imag()))
+ return complex<_Tp>(std::abs(__x.imag()), __x.real());
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf_or_builtin(__x.imag()))
- return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));
- complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1)));
- return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));
+ if (std::__constexpr_isinf(__x.imag()))
+ return complex<_Tp>(std::abs(__x.imag()), std::copysign(__pi/_Tp(2), __x.imag()));
+ complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));
+ return complex<_Tp>(std::copysign(__z.real(), _Tp(0)), std::copysign(__z.imag(), __x.imag()));
}
// atanh
@@ -1204,30 +1277,30 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp>
atanh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.imag()))
{
- return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
+ return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi/_Tp(2), __x.imag()));
}
- if (__libcpp_isnan_or_builtin(__x.imag()))
+ if (std::__constexpr_isnan(__x.imag()))
{
- if (__libcpp_isinf_or_builtin(__x.real()) || __x.real() == 0)
- return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag());
+ if (std::__constexpr_isinf(__x.real()) || __x.real() == 0)
+ return complex<_Tp>(std::copysign(_Tp(0), __x.real()), __x.imag());
return complex<_Tp>(__x.imag(), __x.imag());
}
- if (__libcpp_isnan_or_builtin(__x.real()))
+ if (std::__constexpr_isnan(__x.real()))
{
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__x.real()))
{
- return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
+ return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi/_Tp(2), __x.imag()));
}
- if (abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0))
+ if (std::abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0))
{
- return complex<_Tp>(copysign(_Tp(INFINITY), __x.real()), copysign(_Tp(0), __x.imag()));
+ return complex<_Tp>(std::copysign(_Tp(INFINITY), __x.real()), std::copysign(_Tp(0), __x.imag()));
}
- complex<_Tp> __z = log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2);
- return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
+ complex<_Tp> __z = std::log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2);
+ return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));
}
// sinh
@@ -1236,13 +1309,13 @@ template<class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp>
sinh(const complex<_Tp>& __x)
{
- if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN));
- if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
+ if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN));
- if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
+ if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real()))
return __x;
- return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag()));
+ return complex<_Tp>(std::sinh(__x.real()) * std::cos(__x.imag()), std::cosh(__x.real()) * std::sin(__x.imag()));
}
// cosh
@@ -1251,15 +1324,15 @@ template<class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp>
cosh(const complex<_Tp>& __x)
{
- if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
- return complex<_Tp>(abs(__x.real()), _Tp(NAN));
- if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag()))
+ return complex<_Tp>(std::abs(__x.real()), _Tp(NAN));
+ if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag()))
return complex<_Tp>(_Tp(NAN), __x.real());
if (__x.real() == 0 && __x.imag() == 0)
return complex<_Tp>(_Tp(1), __x.imag());
- if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
- return complex<_Tp>(abs(__x.real()), __x.imag());
- return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag()));
+ if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real()))
+ return complex<_Tp>(std::abs(__x.real()), __x.imag());
+ return complex<_Tp>(std::cosh(__x.real()) * std::cos(__x.imag()), std::sinh(__x.real()) * std::sin(__x.imag()));
}
// tanh
@@ -1268,22 +1341,22 @@ template<class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp>
tanh(const complex<_Tp>& __x)
{
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__x.real()))
{
- if (!__libcpp_isfinite_or_builtin(__x.imag()))
- return complex<_Tp>(copysign(_Tp(1), __x.real()), _Tp(0));
- return complex<_Tp>(copysign(_Tp(1), __x.real()), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));
+ if (!std::__constexpr_isfinite(__x.imag()))
+ return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0));
+ return complex<_Tp>(std::copysign(_Tp(1), __x.real()), std::copysign(_Tp(0), std::sin(_Tp(2) * __x.imag())));
}
- if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)
+ if (std::__constexpr_isnan(__x.real()) && __x.imag() == 0)
return __x;
_Tp __2r(_Tp(2) * __x.real());
_Tp __2i(_Tp(2) * __x.imag());
- _Tp __d(cosh(__2r) + cos(__2i));
- _Tp __2rsh(sinh(__2r));
- if (__libcpp_isinf_or_builtin(__2rsh) && __libcpp_isinf_or_builtin(__d))
+ _Tp __d(std::cosh(__2r) + std::cos(__2i));
+ _Tp __2rsh(std::sinh(__2r));
+ if (std::__constexpr_isinf(__2rsh) && std::__constexpr_isinf(__d))
return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1),
__2i > _Tp(0) ? _Tp(0) : _Tp(-0.));
- return complex<_Tp>(__2rsh/__d, sin(__2i)/__d);
+ return complex<_Tp>(__2rsh/__d, std::sin(__2i)/__d);
}
// asin
@@ -1292,7 +1365,7 @@ template<class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp>
asin(const complex<_Tp>& __x)
{
- complex<_Tp> __z = asinh(complex<_Tp>(-__x.imag(), __x.real()));
+ complex<_Tp> __z = std::asinh(complex<_Tp>(-__x.imag(), __x.real()));
return complex<_Tp>(__z.imag(), -__z.real());
}
@@ -1303,34 +1376,35 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp>
acos(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf_or_builtin(__x.real()))
+ if (std::__constexpr_isinf(__x.real()))
{
- if (__libcpp_isnan_or_builtin(__x.imag()))
+ if (std::__constexpr_isnan(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real());
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.imag()))
{
if (__x.real() < _Tp(0))
return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag());
}
if (__x.real() < _Tp(0))
- return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real());
- return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real());
+ return complex<_Tp>(__pi, std::signbit(__x.imag()) ? -__x.real() : __x.real());
+ return complex<_Tp>(_Tp(0), std::signbit(__x.imag()) ? __x.real() : -__x.real());
}
- if (__libcpp_isnan_or_builtin(__x.real()))
+ if (std::__constexpr_isnan(__x.real()))
{
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.imag()))
return complex<_Tp>(__x.real(), -__x.imag());
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf_or_builtin(__x.imag()))
+ if (std::__constexpr_isinf(__x.imag()))
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
- if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag())))
+ // Somehow isnan can be a macro, so we use __constexpr_isnan
+ if (__x.real() == 0 && (__x.imag() == 0 || std::__constexpr_isnan(__x.imag())))
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
- complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1)));
- if (signbit(__x.imag()))
- return complex<_Tp>(abs(__z.imag()), abs(__z.real()));
- return complex<_Tp>(abs(__z.imag()), -abs(__z.real()));
+ complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));
+ if (std::signbit(__x.imag()))
+ return complex<_Tp>(std::abs(__z.imag()), std::abs(__z.real()));
+ return complex<_Tp>(std::abs(__z.imag()), -std::abs(__z.real()));
}
// atan
@@ -1339,7 +1413,7 @@ template<class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp>
atan(const complex<_Tp>& __x)
{
- complex<_Tp> __z = atanh(complex<_Tp>(-__x.imag(), __x.real()));
+ complex<_Tp> __z = std::atanh(complex<_Tp>(-__x.imag(), __x.real()));
return complex<_Tp>(__z.imag(), -__z.real());
}
@@ -1349,7 +1423,7 @@ template<class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp>
sin(const complex<_Tp>& __x)
{
- complex<_Tp> __z = sinh(complex<_Tp>(-__x.imag(), __x.real()));
+ complex<_Tp> __z = std::sinh(complex<_Tp>(-__x.imag(), __x.real()));
return complex<_Tp>(__z.imag(), -__z.real());
}
@@ -1360,7 +1434,7 @@ inline _LIBCPP_INLINE_VISIBILITY
complex<_Tp>
cos(const complex<_Tp>& __x)
{
- return cosh(complex<_Tp>(-__x.imag(), __x.real()));
+ return std::cosh(complex<_Tp>(-__x.imag(), __x.real()));
}
// tan
@@ -1369,17 +1443,18 @@ template<class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp>
tan(const complex<_Tp>& __x)
{
- complex<_Tp> __z = tanh(complex<_Tp>(-__x.imag(), __x.real()));
+ complex<_Tp> __z = std::tanh(complex<_Tp>(-__x.imag(), __x.real()));
return complex<_Tp>(__z.imag(), -__z.real());
}
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template<class _Tp, class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
{
if (__is.good())
{
- ws(__is);
+ std::ws(__is);
if (__is.peek() == _CharT('('))
{
__is.get();
@@ -1387,7 +1462,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
__is >> __r;
if (!__is.fail())
{
- ws(__is);
+ std::ws(__is);
_CharT __c = __is.peek();
if (__c == _CharT(','))
{
@@ -1396,7 +1471,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
__is >> __i;
if (!__is.fail())
{
- ws(__is);
+ std::ws(__is);
__c = __is.peek();
if (__c == _CharT(')'))
{
@@ -1435,7 +1510,6 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
return __is;
}
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template<class _Tp, class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)