Warning, /include/c++/v1/complex is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009
0010 #ifndef _LIBCPP_COMPLEX
0011 #define _LIBCPP_COMPLEX
0012
0013 /*
0014 complex synopsis
0015
0016 namespace std
0017 {
0018
0019 template<class T>
0020 class complex
0021 {
0022 public:
0023 typedef T value_type;
0024
0025 complex(const T& re = T(), const T& im = T()); // constexpr in C++14
0026 complex(const complex&); // constexpr in C++14
0027 template<class X> complex(const complex<X>&); // constexpr in C++14
0028
0029 T real() const; // constexpr in C++14
0030 T imag() const; // constexpr in C++14
0031
0032 void real(T); // constexpr in C++20
0033 void imag(T); // constexpr in C++20
0034
0035 complex<T>& operator= (const T&); // constexpr in C++20
0036 complex<T>& operator+=(const T&); // constexpr in C++20
0037 complex<T>& operator-=(const T&); // constexpr in C++20
0038 complex<T>& operator*=(const T&); // constexpr in C++20
0039 complex<T>& operator/=(const T&); // constexpr in C++20
0040
0041 complex& operator=(const complex&); // constexpr in C++20
0042 template<class X> complex<T>& operator= (const complex<X>&); // constexpr in C++20
0043 template<class X> complex<T>& operator+=(const complex<X>&); // constexpr in C++20
0044 template<class X> complex<T>& operator-=(const complex<X>&); // constexpr in C++20
0045 template<class X> complex<T>& operator*=(const complex<X>&); // constexpr in C++20
0046 template<class X> complex<T>& operator/=(const complex<X>&); // constexpr in C++20
0047 };
0048
0049 template<>
0050 class complex<float>
0051 {
0052 public:
0053 typedef float value_type;
0054
0055 constexpr complex(float re = 0.0f, float im = 0.0f);
0056 explicit constexpr complex(const complex<double>&);
0057 explicit constexpr complex(const complex<long double>&);
0058
0059 constexpr float real() const;
0060 void real(float); // constexpr in C++20
0061 constexpr float imag() const;
0062 void imag(float); // constexpr in C++20
0063
0064 complex<float>& operator= (float); // constexpr in C++20
0065 complex<float>& operator+=(float); // constexpr in C++20
0066 complex<float>& operator-=(float); // constexpr in C++20
0067 complex<float>& operator*=(float); // constexpr in C++20
0068 complex<float>& operator/=(float); // constexpr in C++20
0069
0070 complex<float>& operator=(const complex<float>&); // constexpr in C++20
0071 template<class X> complex<float>& operator= (const complex<X>&); // constexpr in C++20
0072 template<class X> complex<float>& operator+=(const complex<X>&); // constexpr in C++20
0073 template<class X> complex<float>& operator-=(const complex<X>&); // constexpr in C++20
0074 template<class X> complex<float>& operator*=(const complex<X>&); // constexpr in C++20
0075 template<class X> complex<float>& operator/=(const complex<X>&); // constexpr in C++20
0076 };
0077
0078 template<>
0079 class complex<double>
0080 {
0081 public:
0082 typedef double value_type;
0083
0084 constexpr complex(double re = 0.0, double im = 0.0);
0085 constexpr complex(const complex<float>&);
0086 explicit constexpr complex(const complex<long double>&);
0087
0088 constexpr double real() const;
0089 void real(double); // constexpr in C++20
0090 constexpr double imag() const;
0091 void imag(double); // constexpr in C++20
0092
0093 complex<double>& operator= (double); // constexpr in C++20
0094 complex<double>& operator+=(double); // constexpr in C++20
0095 complex<double>& operator-=(double); // constexpr in C++20
0096 complex<double>& operator*=(double); // constexpr in C++20
0097 complex<double>& operator/=(double); // constexpr in C++20
0098 complex<double>& operator=(const complex<double>&); // constexpr in C++20
0099
0100 template<class X> complex<double>& operator= (const complex<X>&); // constexpr in C++20
0101 template<class X> complex<double>& operator+=(const complex<X>&); // constexpr in C++20
0102 template<class X> complex<double>& operator-=(const complex<X>&); // constexpr in C++20
0103 template<class X> complex<double>& operator*=(const complex<X>&); // constexpr in C++20
0104 template<class X> complex<double>& operator/=(const complex<X>&); // constexpr in C++20
0105 };
0106
0107 template<>
0108 class complex<long double>
0109 {
0110 public:
0111 typedef long double value_type;
0112
0113 constexpr complex(long double re = 0.0L, long double im = 0.0L);
0114 constexpr complex(const complex<float>&);
0115 constexpr complex(const complex<double>&);
0116
0117 constexpr long double real() const;
0118 void real(long double); // constexpr in C++20
0119 constexpr long double imag() const;
0120 void imag(long double); // constexpr in C++20
0121
0122 complex<long double>& operator=(const complex<long double>&); // constexpr in C++20
0123 complex<long double>& operator= (long double); // constexpr in C++20
0124 complex<long double>& operator+=(long double); // constexpr in C++20
0125 complex<long double>& operator-=(long double); // constexpr in C++20
0126 complex<long double>& operator*=(long double); // constexpr in C++20
0127 complex<long double>& operator/=(long double); // constexpr in C++20
0128
0129 template<class X> complex<long double>& operator= (const complex<X>&); // constexpr in C++20
0130 template<class X> complex<long double>& operator+=(const complex<X>&); // constexpr in C++20
0131 template<class X> complex<long double>& operator-=(const complex<X>&); // constexpr in C++20
0132 template<class X> complex<long double>& operator*=(const complex<X>&); // constexpr in C++20
0133 template<class X> complex<long double>& operator/=(const complex<X>&); // constexpr in C++20
0134 };
0135
0136 // 26.3.6 operators:
0137 template<class T> complex<T> operator+(const complex<T>&, const complex<T>&); // constexpr in C++20
0138 template<class T> complex<T> operator+(const complex<T>&, const T&); // constexpr in C++20
0139 template<class T> complex<T> operator+(const T&, const complex<T>&); // constexpr in C++20
0140 template<class T> complex<T> operator-(const complex<T>&, const complex<T>&); // constexpr in C++20
0141 template<class T> complex<T> operator-(const complex<T>&, const T&); // constexpr in C++20
0142 template<class T> complex<T> operator-(const T&, const complex<T>&); // constexpr in C++20
0143 template<class T> complex<T> operator*(const complex<T>&, const complex<T>&); // constexpr in C++20
0144 template<class T> complex<T> operator*(const complex<T>&, const T&); // constexpr in C++20
0145 template<class T> complex<T> operator*(const T&, const complex<T>&); // constexpr in C++20
0146 template<class T> complex<T> operator/(const complex<T>&, const complex<T>&); // constexpr in C++20
0147 template<class T> complex<T> operator/(const complex<T>&, const T&); // constexpr in C++20
0148 template<class T> complex<T> operator/(const T&, const complex<T>&); // constexpr in C++20
0149 template<class T> complex<T> operator+(const complex<T>&); // constexpr in C++20
0150 template<class T> complex<T> operator-(const complex<T>&); // constexpr in C++20
0151 template<class T> bool operator==(const complex<T>&, const complex<T>&); // constexpr in C++14
0152 template<class T> bool operator==(const complex<T>&, const T&); // constexpr in C++14
0153 template<class T> bool operator==(const T&, const complex<T>&); // constexpr in C++14, removed in C++20
0154 template<class T> bool operator!=(const complex<T>&, const complex<T>&); // constexpr in C++14, removed in C++20
0155 template<class T> bool operator!=(const complex<T>&, const T&); // constexpr in C++14, removed in C++20
0156 template<class T> bool operator!=(const T&, const complex<T>&); // constexpr in C++14, removed in C++20
0157
0158 template<class T, class charT, class traits>
0159 basic_istream<charT, traits>&
0160 operator>>(basic_istream<charT, traits>&, complex<T>&);
0161 template<class T, class charT, class traits>
0162 basic_ostream<charT, traits>&
0163 operator<<(basic_ostream<charT, traits>&, const complex<T>&);
0164
0165 // 26.3.7 values:
0166
0167 template<class T> T real(const complex<T>&); // constexpr in C++14
0168 long double real(long double); // constexpr in C++14
0169 double real(double); // constexpr in C++14
0170 template<Integral T> double real(T); // constexpr in C++14
0171 float real(float); // constexpr in C++14
0172
0173 template<class T> T imag(const complex<T>&); // constexpr in C++14
0174 long double imag(long double); // constexpr in C++14
0175 double imag(double); // constexpr in C++14
0176 template<Integral T> double imag(T); // constexpr in C++14
0177 float imag(float); // constexpr in C++14
0178
0179 template<class T> T abs(const complex<T>&);
0180
0181 template<class T> T arg(const complex<T>&);
0182 long double arg(long double);
0183 double arg(double);
0184 template<Integral T> double arg(T);
0185 float arg(float);
0186
0187 template<class T> T norm(const complex<T>&); // constexpr in C++20
0188 long double norm(long double); // constexpr in C++20
0189 double norm(double); // constexpr in C++20
0190 template<Integral T> double norm(T); // constexpr in C++20
0191 float norm(float); // constexpr in C++20
0192
0193 template<class T> complex<T> conj(const complex<T>&); // constexpr in C++20
0194 complex<long double> conj(long double); // constexpr in C++20
0195 complex<double> conj(double); // constexpr in C++20
0196 template<Integral T> complex<double> conj(T); // constexpr in C++20
0197 complex<float> conj(float); // constexpr in C++20
0198
0199 template<class T> complex<T> proj(const complex<T>&);
0200 complex<long double> proj(long double);
0201 complex<double> proj(double);
0202 template<Integral T> complex<double> proj(T);
0203 complex<float> proj(float);
0204
0205 template<class T> complex<T> polar(const T&, const T& = T());
0206
0207 // 26.3.8 transcendentals:
0208 template<class T> complex<T> acos(const complex<T>&);
0209 template<class T> complex<T> asin(const complex<T>&);
0210 template<class T> complex<T> atan(const complex<T>&);
0211 template<class T> complex<T> acosh(const complex<T>&);
0212 template<class T> complex<T> asinh(const complex<T>&);
0213 template<class T> complex<T> atanh(const complex<T>&);
0214 template<class T> complex<T> cos (const complex<T>&);
0215 template<class T> complex<T> cosh (const complex<T>&);
0216 template<class T> complex<T> exp (const complex<T>&);
0217 template<class T> complex<T> log (const complex<T>&);
0218 template<class T> complex<T> log10(const complex<T>&);
0219
0220 template<class T> complex<T> pow(const complex<T>&, const T&);
0221 template<class T> complex<T> pow(const complex<T>&, const complex<T>&);
0222 template<class T> complex<T> pow(const T&, const complex<T>&);
0223
0224 template<class T> complex<T> sin (const complex<T>&);
0225 template<class T> complex<T> sinh (const complex<T>&);
0226 template<class T> complex<T> sqrt (const complex<T>&);
0227 template<class T> complex<T> tan (const complex<T>&);
0228 template<class T> complex<T> tanh (const complex<T>&);
0229
0230 // [complex.tuple], tuple interface
0231 template<class T> struct tuple_size; // Since C++26
0232 template<size_t I, class T> struct tuple_element; // Since C++26
0233 template<class T> struct tuple_size<complex<T>>; // Since C++26
0234 template<size_t I, class T> struct tuple_element<I, complex<T>>; // Since C++26
0235 template<size_t I, class T>
0236 constexpr T& get(complex<T>&) noexcept; // Since C++26
0237 template<size_t I, class T>
0238 constexpr T&& get(complex<T>&&) noexcept; // Since C++26
0239 template<size_t I, class T>
0240 constexpr const T& get(const complex<T>&) noexcept; // Since C++26
0241 template<size_t I, class T>
0242 constexpr const T&& get(const complex<T>&&) noexcept; // Since C++26
0243
0244 // [complex.literals], complex literals
0245 inline namespace literals {
0246 inline namespace complex_literals {
0247 constexpr complex<long double> operator""il(long double); // Since C++14
0248 constexpr complex<long double> operator""il(unsigned long long); // Since C++14
0249 constexpr complex<double> operator""i(long double); // Since C++14
0250 constexpr complex<double> operator""i(unsigned long long); // Since C++14
0251 constexpr complex<float> operator""if(long double); // Since C++14
0252 constexpr complex<float> operator""if(unsigned long long); // Since C++14
0253 }
0254 }
0255 } // std
0256
0257 */
0258
0259 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0260 # include <__cxx03/complex>
0261 #else
0262 # include <__config>
0263 # include <__fwd/complex.h>
0264 # include <__fwd/tuple.h>
0265 # include <__tuple/tuple_element.h>
0266 # include <__tuple/tuple_size.h>
0267 # include <__type_traits/conditional.h>
0268 # include <__utility/move.h>
0269 # include <cmath>
0270 # include <version>
0271
0272 # if _LIBCPP_HAS_LOCALIZATION
0273 # include <sstream> // for std::basic_ostringstream
0274 # endif
0275
0276 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0277 # pragma GCC system_header
0278 # endif
0279
0280 _LIBCPP_PUSH_MACROS
0281 # include <__undef_macros>
0282
0283 _LIBCPP_BEGIN_NAMESPACE_STD
0284
0285 template <class _Tp>
0286 class _LIBCPP_TEMPLATE_VIS complex;
0287
0288 template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>
0289 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0290 operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
0291
0292 template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> = 0>
0293 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0294 operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
0295
0296 template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>
0297 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0298 operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
0299
0300 template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> = 0>
0301 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0302 operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
0303
0304 template <class _Tp>
0305 class _LIBCPP_TEMPLATE_VIS complex {
0306 public:
0307 typedef _Tp value_type;
0308
0309 private:
0310 value_type __re_;
0311 value_type __im_;
0312
0313 public:
0314 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
0315 complex(const value_type& __re = value_type(), const value_type& __im = value_type())
0316 : __re_(__re), __im_(__im) {}
0317 template <class _Xp>
0318 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 complex(const complex<_Xp>& __c)
0319 : __re_(__c.real()), __im_(__c.imag()) {}
0320
0321 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 value_type real() const { return __re_; }
0322 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 value_type imag() const { return __im_; }
0323
0324 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; }
0325 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; }
0326
0327 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(const value_type& __re) {
0328 __re_ = __re;
0329 __im_ = value_type();
0330 return *this;
0331 }
0332 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const value_type& __re) {
0333 __re_ += __re;
0334 return *this;
0335 }
0336 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const value_type& __re) {
0337 __re_ -= __re;
0338 return *this;
0339 }
0340 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const value_type& __re) {
0341 __re_ *= __re;
0342 __im_ *= __re;
0343 return *this;
0344 }
0345 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const value_type& __re) {
0346 __re_ /= __re;
0347 __im_ /= __re;
0348 return *this;
0349 }
0350
0351 template <class _Xp>
0352 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(const complex<_Xp>& __c) {
0353 __re_ = __c.real();
0354 __im_ = __c.imag();
0355 return *this;
0356 }
0357 template <class _Xp>
0358 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const complex<_Xp>& __c) {
0359 __re_ += __c.real();
0360 __im_ += __c.imag();
0361 return *this;
0362 }
0363 template <class _Xp>
0364 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const complex<_Xp>& __c) {
0365 __re_ -= __c.real();
0366 __im_ -= __c.imag();
0367 return *this;
0368 }
0369 template <class _Xp>
0370 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const complex<_Xp>& __c) {
0371 *this = *this * complex(__c.real(), __c.imag());
0372 return *this;
0373 }
0374 template <class _Xp>
0375 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c) {
0376 *this = *this / complex(__c.real(), __c.imag());
0377 return *this;
0378 }
0379
0380 # if _LIBCPP_STD_VER >= 26
0381 template <size_t _Ip, class _Xp>
0382 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;
0383
0384 template <size_t _Ip, class _Xp>
0385 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&&) noexcept;
0386
0387 template <size_t _Ip, class _Xp>
0388 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>&) noexcept;
0389
0390 template <size_t _Ip, class _Xp>
0391 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;
0392 # endif
0393 };
0394
0395 template <>
0396 class _LIBCPP_TEMPLATE_VIS complex<double>;
0397 template <>
0398 class _LIBCPP_TEMPLATE_VIS complex<long double>;
0399
0400 struct __from_builtin_tag {};
0401
0402 template <class _Tp>
0403 using __complex_t _LIBCPP_NODEBUG =
0404 __conditional_t<is_same<_Tp, float>::value,
0405 _Complex float,
0406 __conditional_t<is_same<_Tp, double>::value, _Complex double, _Complex long double> >;
0407
0408 template <class _Tp>
0409 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __complex_t<_Tp> __make_complex(_Tp __re, _Tp __im) {
0410 # if __has_builtin(__builtin_complex)
0411 return __builtin_complex(__re, __im);
0412 # else
0413 return __complex_t<_Tp>{__re, __im};
0414 # endif
0415 }
0416
0417 template <>
0418 class _LIBCPP_TEMPLATE_VIS complex<float> {
0419 float __re_;
0420 float __im_;
0421
0422 public:
0423 typedef float value_type;
0424
0425 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(float __re = 0.0f, float __im = 0.0f) : __re_(__re), __im_(__im) {}
0426
0427 template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0>
0428 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex float __v)
0429 : __re_(__real__ __v), __im_(__imag__ __v) {}
0430
0431 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
0432 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
0433
0434 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR float real() const { return __re_; }
0435 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR float imag() const { return __im_; }
0436
0437 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; }
0438 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; }
0439
0440 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Complex float __builtin() const { return std::__make_complex(__re_, __im_); }
0441 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __builtin(_Complex float __f) {
0442 __re_ = __real__ __f;
0443 __im_ = __imag__ __f;
0444 }
0445
0446 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(float __re) {
0447 __re_ = __re;
0448 __im_ = value_type();
0449 return *this;
0450 }
0451 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(float __re) {
0452 __re_ += __re;
0453 return *this;
0454 }
0455 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(float __re) {
0456 __re_ -= __re;
0457 return *this;
0458 }
0459 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(float __re) {
0460 __re_ *= __re;
0461 __im_ *= __re;
0462 return *this;
0463 }
0464 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(float __re) {
0465 __re_ /= __re;
0466 __im_ /= __re;
0467 return *this;
0468 }
0469
0470 template <class _Xp>
0471 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(const complex<_Xp>& __c) {
0472 __re_ = __c.real();
0473 __im_ = __c.imag();
0474 return *this;
0475 }
0476 template <class _Xp>
0477 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const complex<_Xp>& __c) {
0478 __re_ += __c.real();
0479 __im_ += __c.imag();
0480 return *this;
0481 }
0482 template <class _Xp>
0483 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const complex<_Xp>& __c) {
0484 __re_ -= __c.real();
0485 __im_ -= __c.imag();
0486 return *this;
0487 }
0488 template <class _Xp>
0489 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const complex<_Xp>& __c) {
0490 *this = *this * complex(__c.real(), __c.imag());
0491 return *this;
0492 }
0493 template <class _Xp>
0494 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c) {
0495 *this = *this / complex(__c.real(), __c.imag());
0496 return *this;
0497 }
0498
0499 # if _LIBCPP_STD_VER >= 26
0500 template <size_t _Ip, class _Xp>
0501 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;
0502
0503 template <size_t _Ip, class _Xp>
0504 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&&) noexcept;
0505
0506 template <size_t _Ip, class _Xp>
0507 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>&) noexcept;
0508
0509 template <size_t _Ip, class _Xp>
0510 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;
0511 # endif
0512 };
0513
0514 template <>
0515 class _LIBCPP_TEMPLATE_VIS complex<double> {
0516 double __re_;
0517 double __im_;
0518
0519 public:
0520 typedef double value_type;
0521
0522 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(double __re = 0.0, double __im = 0.0) : __re_(__re), __im_(__im) {}
0523
0524 template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0>
0525 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex double __v)
0526 : __re_(__real__ __v), __im_(__imag__ __v) {}
0527
0528 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
0529 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
0530
0531 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double real() const { return __re_; }
0532 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double imag() const { return __im_; }
0533
0534 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; }
0535 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; }
0536
0537 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Complex double __builtin() const {
0538 return std::__make_complex(__re_, __im_);
0539 }
0540
0541 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __builtin(_Complex double __f) {
0542 __re_ = __real__ __f;
0543 __im_ = __imag__ __f;
0544 }
0545
0546 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(double __re) {
0547 __re_ = __re;
0548 __im_ = value_type();
0549 return *this;
0550 }
0551 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(double __re) {
0552 __re_ += __re;
0553 return *this;
0554 }
0555 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(double __re) {
0556 __re_ -= __re;
0557 return *this;
0558 }
0559 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(double __re) {
0560 __re_ *= __re;
0561 __im_ *= __re;
0562 return *this;
0563 }
0564 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(double __re) {
0565 __re_ /= __re;
0566 __im_ /= __re;
0567 return *this;
0568 }
0569
0570 template <class _Xp>
0571 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(const complex<_Xp>& __c) {
0572 __re_ = __c.real();
0573 __im_ = __c.imag();
0574 return *this;
0575 }
0576 template <class _Xp>
0577 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const complex<_Xp>& __c) {
0578 __re_ += __c.real();
0579 __im_ += __c.imag();
0580 return *this;
0581 }
0582 template <class _Xp>
0583 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const complex<_Xp>& __c) {
0584 __re_ -= __c.real();
0585 __im_ -= __c.imag();
0586 return *this;
0587 }
0588 template <class _Xp>
0589 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const complex<_Xp>& __c) {
0590 *this = *this * complex(__c.real(), __c.imag());
0591 return *this;
0592 }
0593 template <class _Xp>
0594 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c) {
0595 *this = *this / complex(__c.real(), __c.imag());
0596 return *this;
0597 }
0598
0599 # if _LIBCPP_STD_VER >= 26
0600 template <size_t _Ip, class _Xp>
0601 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;
0602
0603 template <size_t _Ip, class _Xp>
0604 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&&) noexcept;
0605
0606 template <size_t _Ip, class _Xp>
0607 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>&) noexcept;
0608
0609 template <size_t _Ip, class _Xp>
0610 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;
0611 # endif
0612 };
0613
0614 template <>
0615 class _LIBCPP_TEMPLATE_VIS complex<long double> {
0616 long double __re_;
0617 long double __im_;
0618
0619 public:
0620 typedef long double value_type;
0621
0622 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(long double __re = 0.0L, long double __im = 0.0L)
0623 : __re_(__re), __im_(__im) {}
0624
0625 template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0>
0626 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex long double __v)
0627 : __re_(__real__ __v), __im_(__imag__ __v) {}
0628
0629 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
0630 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
0631
0632 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long double real() const { return __re_; }
0633 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long double imag() const { return __im_; }
0634
0635 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; }
0636 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; }
0637
0638 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Complex long double __builtin() const {
0639 return std::__make_complex(__re_, __im_);
0640 }
0641
0642 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __builtin(_Complex long double __f) {
0643 __re_ = __real__ __f;
0644 __im_ = __imag__ __f;
0645 }
0646
0647 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(long double __re) {
0648 __re_ = __re;
0649 __im_ = value_type();
0650 return *this;
0651 }
0652 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(long double __re) {
0653 __re_ += __re;
0654 return *this;
0655 }
0656 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(long double __re) {
0657 __re_ -= __re;
0658 return *this;
0659 }
0660 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(long double __re) {
0661 __re_ *= __re;
0662 __im_ *= __re;
0663 return *this;
0664 }
0665 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(long double __re) {
0666 __re_ /= __re;
0667 __im_ /= __re;
0668 return *this;
0669 }
0670
0671 template <class _Xp>
0672 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(const complex<_Xp>& __c) {
0673 __re_ = __c.real();
0674 __im_ = __c.imag();
0675 return *this;
0676 }
0677 template <class _Xp>
0678 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const complex<_Xp>& __c) {
0679 __re_ += __c.real();
0680 __im_ += __c.imag();
0681 return *this;
0682 }
0683 template <class _Xp>
0684 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const complex<_Xp>& __c) {
0685 __re_ -= __c.real();
0686 __im_ -= __c.imag();
0687 return *this;
0688 }
0689 template <class _Xp>
0690 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const complex<_Xp>& __c) {
0691 *this = *this * complex(__c.real(), __c.imag());
0692 return *this;
0693 }
0694 template <class _Xp>
0695 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c) {
0696 *this = *this / complex(__c.real(), __c.imag());
0697 return *this;
0698 }
0699
0700 # if _LIBCPP_STD_VER >= 26
0701 template <size_t _Ip, class _Xp>
0702 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;
0703
0704 template <size_t _Ip, class _Xp>
0705 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&&) noexcept;
0706
0707 template <size_t _Ip, class _Xp>
0708 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>&) noexcept;
0709
0710 template <size_t _Ip, class _Xp>
0711 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;
0712 # endif
0713 };
0714
0715 inline _LIBCPP_CONSTEXPR complex<float>::complex(const complex<double>& __c) : __re_(__c.real()), __im_(__c.imag()) {}
0716
0717 inline _LIBCPP_CONSTEXPR complex<float>::complex(const complex<long double>& __c)
0718 : __re_(__c.real()), __im_(__c.imag()) {}
0719
0720 inline _LIBCPP_CONSTEXPR complex<double>::complex(const complex<float>& __c) : __re_(__c.real()), __im_(__c.imag()) {}
0721
0722 inline _LIBCPP_CONSTEXPR complex<double>::complex(const complex<long double>& __c)
0723 : __re_(__c.real()), __im_(__c.imag()) {}
0724
0725 inline _LIBCPP_CONSTEXPR complex<long double>::complex(const complex<float>& __c)
0726 : __re_(__c.real()), __im_(__c.imag()) {}
0727
0728 inline _LIBCPP_CONSTEXPR complex<long double>::complex(const complex<double>& __c)
0729 : __re_(__c.real()), __im_(__c.imag()) {}
0730
0731 // 26.3.6 operators:
0732
0733 template <class _Tp>
0734 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0735 operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) {
0736 complex<_Tp> __t(__x);
0737 __t += __y;
0738 return __t;
0739 }
0740
0741 template <class _Tp>
0742 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0743 operator+(const complex<_Tp>& __x, const _Tp& __y) {
0744 complex<_Tp> __t(__x);
0745 __t += __y;
0746 return __t;
0747 }
0748
0749 template <class _Tp>
0750 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0751 operator+(const _Tp& __x, const complex<_Tp>& __y) {
0752 complex<_Tp> __t(__y);
0753 __t += __x;
0754 return __t;
0755 }
0756
0757 template <class _Tp>
0758 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0759 operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) {
0760 complex<_Tp> __t(__x);
0761 __t -= __y;
0762 return __t;
0763 }
0764
0765 template <class _Tp>
0766 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0767 operator-(const complex<_Tp>& __x, const _Tp& __y) {
0768 complex<_Tp> __t(__x);
0769 __t -= __y;
0770 return __t;
0771 }
0772
0773 template <class _Tp>
0774 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0775 operator-(const _Tp& __x, const complex<_Tp>& __y) {
0776 complex<_Tp> __t(-__y);
0777 __t += __x;
0778 return __t;
0779 }
0780
0781 template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> >
0782 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0783 operator*(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) {
0784 return complex<_Tp>(__from_builtin_tag(), __lhs.__builtin() * __rhs.__builtin());
0785 }
0786
0787 template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> >
0788 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0789 operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) {
0790 _Tp __a = __z.real();
0791 _Tp __b = __z.imag();
0792 _Tp __c = __w.real();
0793 _Tp __d = __w.imag();
0794
0795 return complex<_Tp>((__a * __c) - (__b * __d), (__a * __d) + (__b * __c));
0796 }
0797
0798 template <class _Tp>
0799 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0800 operator*(const complex<_Tp>& __x, const _Tp& __y) {
0801 complex<_Tp> __t(__x);
0802 __t *= __y;
0803 return __t;
0804 }
0805
0806 template <class _Tp>
0807 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0808 operator*(const _Tp& __x, const complex<_Tp>& __y) {
0809 complex<_Tp> __t(__y);
0810 __t *= __x;
0811 return __t;
0812 }
0813
0814 template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> >
0815 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0816 operator/(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) {
0817 return complex<_Tp>(__from_builtin_tag(), __lhs.__builtin() / __rhs.__builtin());
0818 }
0819
0820 template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> >
0821 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0822 operator/(const complex<_Tp>& __z, const complex<_Tp>& __w) {
0823 _Tp __a = __z.real();
0824 _Tp __b = __z.imag();
0825 _Tp __c = __w.real();
0826 _Tp __d = __w.imag();
0827
0828 _Tp __denom = __c * __c + __d * __d;
0829 return complex<_Tp>((__a * __c + __b * __d) / __denom, (__b * __c - __a * __d) / __denom);
0830 }
0831
0832 template <class _Tp>
0833 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0834 operator/(const complex<_Tp>& __x, const _Tp& __y) {
0835 return complex<_Tp>(__x.real() / __y, __x.imag() / __y);
0836 }
0837
0838 template <class _Tp>
0839 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
0840 operator/(const _Tp& __x, const complex<_Tp>& __y) {
0841 complex<_Tp> __t(__x);
0842 __t /= __y;
0843 return __t;
0844 }
0845
0846 template <class _Tp>
0847 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator+(const complex<_Tp>& __x) {
0848 return __x;
0849 }
0850
0851 template <class _Tp>
0852 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator-(const complex<_Tp>& __x) {
0853 return complex<_Tp>(-__x.real(), -__x.imag());
0854 }
0855
0856 template <class _Tp>
0857 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
0858 operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) {
0859 return __x.real() == __y.real() && __x.imag() == __y.imag();
0860 }
0861
0862 template <class _Tp>
0863 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const complex<_Tp>& __x, const _Tp& __y) {
0864 return __x.real() == __y && __x.imag() == 0;
0865 }
0866
0867 # if _LIBCPP_STD_VER <= 17
0868
0869 template <class _Tp>
0870 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const _Tp& __x, const complex<_Tp>& __y) {
0871 return __x == __y.real() && 0 == __y.imag();
0872 }
0873
0874 template <class _Tp>
0875 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
0876 operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) {
0877 return !(__x == __y);
0878 }
0879
0880 template <class _Tp>
0881 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator!=(const complex<_Tp>& __x, const _Tp& __y) {
0882 return !(__x == __y);
0883 }
0884
0885 template <class _Tp>
0886 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator!=(const _Tp& __x, const complex<_Tp>& __y) {
0887 return !(__x == __y);
0888 }
0889
0890 # endif
0891
0892 // 26.3.7 values:
0893
0894 template <class _Tp, bool = is_integral<_Tp>::value, bool = is_floating_point<_Tp>::value >
0895 struct __libcpp_complex_overload_traits {};
0896
0897 // Integral Types
0898 template <class _Tp>
0899 struct __libcpp_complex_overload_traits<_Tp, true, false> {
0900 typedef double _ValueType;
0901 typedef complex<double> _ComplexType;
0902 };
0903
0904 // Floating point types
0905 template <class _Tp>
0906 struct __libcpp_complex_overload_traits<_Tp, false, true> {
0907 typedef _Tp _ValueType;
0908 typedef complex<_Tp> _ComplexType;
0909 };
0910
0911 // real
0912
0913 template <class _Tp>
0914 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp real(const complex<_Tp>& __c) {
0915 return __c.real();
0916 }
0917
0918 template <class _Tp>
0919 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __libcpp_complex_overload_traits<_Tp>::_ValueType
0920 real(_Tp __re) {
0921 return __re;
0922 }
0923
0924 // imag
0925
0926 template <class _Tp>
0927 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp imag(const complex<_Tp>& __c) {
0928 return __c.imag();
0929 }
0930
0931 template <class _Tp>
0932 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __libcpp_complex_overload_traits<_Tp>::_ValueType
0933 imag(_Tp) {
0934 return 0;
0935 }
0936
0937 // abs
0938
0939 template <class _Tp>
0940 inline _LIBCPP_HIDE_FROM_ABI _Tp abs(const complex<_Tp>& __c) {
0941 return std::hypot(__c.real(), __c.imag());
0942 }
0943
0944 // arg
0945
0946 template <class _Tp>
0947 inline _LIBCPP_HIDE_FROM_ABI _Tp arg(const complex<_Tp>& __c) {
0948 return std::atan2(__c.imag(), __c.real());
0949 }
0950
0951 template <class _Tp, __enable_if_t<is_same<_Tp, long double>::value, int> = 0>
0952 inline _LIBCPP_HIDE_FROM_ABI long double arg(_Tp __re) {
0953 return std::atan2l(0.L, __re);
0954 }
0955
0956 template <class _Tp, __enable_if_t<is_integral<_Tp>::value || is_same<_Tp, double>::value, int> = 0>
0957 inline _LIBCPP_HIDE_FROM_ABI double arg(_Tp __re) {
0958 return std::atan2(0., __re);
0959 }
0960
0961 template <class _Tp, __enable_if_t<is_same<_Tp, float>::value, int> = 0>
0962 inline _LIBCPP_HIDE_FROM_ABI float arg(_Tp __re) {
0963 return std::atan2f(0.F, __re);
0964 }
0965
0966 // norm
0967
0968 template <class _Tp>
0969 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp norm(const complex<_Tp>& __c) {
0970 if (std::__constexpr_isinf(__c.real()))
0971 return std::abs(__c.real());
0972 if (std::__constexpr_isinf(__c.imag()))
0973 return std::abs(__c.imag());
0974 return __c.real() * __c.real() + __c.imag() * __c.imag();
0975 }
0976
0977 template <class _Tp>
0978 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __libcpp_complex_overload_traits<_Tp>::_ValueType
0979 norm(_Tp __re) {
0980 typedef typename __libcpp_complex_overload_traits<_Tp>::_ValueType _ValueType;
0981 return static_cast<_ValueType>(__re) * __re;
0982 }
0983
0984 // conj
0985
0986 template <class _Tp>
0987 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> conj(const complex<_Tp>& __c) {
0988 return complex<_Tp>(__c.real(), -__c.imag());
0989 }
0990
0991 template <class _Tp>
0992 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
0993 conj(_Tp __re) {
0994 typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType;
0995 return _ComplexType(__re);
0996 }
0997
0998 // proj
0999
1000 template <class _Tp>
1001 inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> proj(const complex<_Tp>& __c) {
1002 complex<_Tp> __r = __c;
1003 if (std::isinf(__c.real()) || std::isinf(__c.imag()))
1004 __r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag()));
1005 return __r;
1006 }
1007
1008 template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>
1009 inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) {
1010 if (std::isinf(__re))
1011 __re = std::abs(__re);
1012 return complex<_Tp>(__re);
1013 }
1014
1015 template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
1016 inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) {
1017 typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType;
1018 return _ComplexType(__re);
1019 }
1020
1021 // polar
1022
1023 template <class _Tp>
1024 _LIBCPP_HIDE_FROM_ABI complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta = _Tp()) {
1025 if (std::isnan(__rho) || std::signbit(__rho))
1026 return complex<_Tp>(_Tp(NAN), _Tp(NAN));
1027 if (std::isnan(__theta)) {
1028 if (std::isinf(__rho))
1029 return complex<_Tp>(__rho, __theta);
1030 return complex<_Tp>(__theta, __theta);
1031 }
1032 if (std::isinf(__theta)) {
1033 if (std::isinf(__rho))
1034 return complex<_Tp>(__rho, _Tp(NAN));
1035 return complex<_Tp>(_Tp(NAN), _Tp(NAN));
1036 }
1037 _Tp __x = __rho * std::cos(__theta);
1038 if (std::isnan(__x))
1039 __x = 0;
1040 _Tp __y = __rho * std::sin(__theta);
1041 if (std::isnan(__y))
1042 __y = 0;
1043 return complex<_Tp>(__x, __y);
1044 }
1045
1046 // log
1047
1048 template <class _Tp>
1049 inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log(const complex<_Tp>& __x) {
1050 return complex<_Tp>(std::log(std::abs(__x)), std::arg(__x));
1051 }
1052
1053 // log10
1054
1055 template <class _Tp>
1056 inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log10(const complex<_Tp>& __x) {
1057 return std::log(__x) / std::log(_Tp(10));
1058 }
1059
1060 // sqrt
1061
1062 template <class _Tp>
1063 _LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) {
1064 if (std::isinf(__x.imag()))
1065 return complex<_Tp>(_Tp(INFINITY), __x.imag());
1066 if (std::isinf(__x.real())) {
1067 if (__x.real() > _Tp(0))
1068 return complex<_Tp>(__x.real(), std::isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag()));
1069 return complex<_Tp>(std::isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag()));
1070 }
1071 return std::polar(std::sqrt(std::abs(__x)), std::arg(__x) / _Tp(2));
1072 }
1073
1074 // exp
1075
1076 template <class _Tp>
1077 _LIBCPP_HIDE_FROM_ABI complex<_Tp> exp(const complex<_Tp>& __x) {
1078 _Tp __i = __x.imag();
1079 if (__i == 0) {
1080 return complex<_Tp>(std::exp(__x.real()), std::copysign(_Tp(0), __x.imag()));
1081 }
1082 if (std::isinf(__x.real())) {
1083 if (__x.real() < _Tp(0)) {
1084 if (!std::isfinite(__i))
1085 __i = _Tp(1);
1086 } else if (__i == 0 || !std::isfinite(__i)) {
1087 if (std::isinf(__i))
1088 __i = _Tp(NAN);
1089 return complex<_Tp>(__x.real(), __i);
1090 }
1091 }
1092 _Tp __e = std::exp(__x.real());
1093 return complex<_Tp>(__e * std::cos(__i), __e * std::sin(__i));
1094 }
1095
1096 // pow
1097
1098 template <class _Tp>
1099 inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> pow(const complex<_Tp>& __x, const complex<_Tp>& __y) {
1100 return std::exp(__y * std::log(__x));
1101 }
1102
1103 template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_floating_point<_Up>::value, int> = 0>
1104 inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type>
1105 pow(const complex<_Tp>& __x, const complex<_Up>& __y) {
1106 typedef complex<typename __promote<_Tp, _Up>::type> result_type;
1107 return std::pow(result_type(__x), result_type(__y));
1108 }
1109
1110 template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_arithmetic<_Up>::value, int> = 0>
1111 inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const complex<_Tp>& __x, const _Up& __y) {
1112 typedef complex<typename __promote<_Tp, _Up>::type> result_type;
1113 return std::pow(result_type(__x), result_type(__y));
1114 }
1115
1116 template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_floating_point<_Up>::value, int> = 0>
1117 inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const _Tp& __x, const complex<_Up>& __y) {
1118 typedef complex<typename __promote<_Tp, _Up>::type> result_type;
1119 return std::pow(result_type(__x), result_type(__y));
1120 }
1121
1122 // __sqr, computes pow(x, 2)
1123
1124 template <class _Tp>
1125 inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> __sqr(const complex<_Tp>& __x) {
1126 return complex<_Tp>((__x.real() - __x.imag()) * (__x.real() + __x.imag()), _Tp(2) * __x.real() * __x.imag());
1127 }
1128
1129 // asinh
1130
1131 template <class _Tp>
1132 _LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) {
1133 const _Tp __pi(atan2(+0., -0.));
1134 if (std::isinf(__x.real())) {
1135 if (std::isnan(__x.imag()))
1136 return __x;
1137 if (std::isinf(__x.imag()))
1138 return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
1139 return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
1140 }
1141 if (std::isnan(__x.real())) {
1142 if (std::isinf(__x.imag()))
1143 return complex<_Tp>(__x.imag(), __x.real());
1144 if (__x.imag() == 0)
1145 return __x;
1146 return complex<_Tp>(__x.real(), __x.real());
1147 }
1148 if (std::isinf(__x.imag()))
1149 return complex<_Tp>(std::copysign(__x.imag(), __x.real()), std::copysign(__pi / _Tp(2), __x.imag()));
1150 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) + _Tp(1)));
1151 return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));
1152 }
1153
1154 // acosh
1155
1156 template <class _Tp>
1157 _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) {
1158 const _Tp __pi(atan2(+0., -0.));
1159 if (std::isinf(__x.real())) {
1160 if (std::isnan(__x.imag()))
1161 return complex<_Tp>(std::abs(__x.real()), __x.imag());
1162 if (std::isinf(__x.imag())) {
1163 if (__x.real() > 0)
1164 return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
1165 else
1166 return complex<_Tp>(-__x.real(), std::copysign(__pi * _Tp(0.75), __x.imag()));
1167 }
1168 if (__x.real() < 0)
1169 return complex<_Tp>(-__x.real(), std::copysign(__pi, __x.imag()));
1170 return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
1171 }
1172 if (std::isnan(__x.real())) {
1173 if (std::isinf(__x.imag()))
1174 return complex<_Tp>(std::abs(__x.imag()), __x.real());
1175 return complex<_Tp>(__x.real(), __x.real());
1176 }
1177 if (std::isinf(__x.imag()))
1178 return complex<_Tp>(std::abs(__x.imag()), std::copysign(__pi / _Tp(2), __x.imag()));
1179 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));
1180 return complex<_Tp>(std::copysign(__z.real(), _Tp(0)), std::copysign(__z.imag(), __x.imag()));
1181 }
1182
1183 // atanh
1184
1185 template <class _Tp>
1186 _LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) {
1187 const _Tp __pi(atan2(+0., -0.));
1188 if (std::isinf(__x.imag())) {
1189 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag()));
1190 }
1191 if (std::isnan(__x.imag())) {
1192 if (std::isinf(__x.real()) || __x.real() == 0)
1193 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), __x.imag());
1194 return complex<_Tp>(__x.imag(), __x.imag());
1195 }
1196 if (std::isnan(__x.real())) {
1197 return complex<_Tp>(__x.real(), __x.real());
1198 }
1199 if (std::isinf(__x.real())) {
1200 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag()));
1201 }
1202 if (std::abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0)) {
1203 return complex<_Tp>(std::copysign(_Tp(INFINITY), __x.real()), std::copysign(_Tp(0), __x.imag()));
1204 }
1205 complex<_Tp> __z = std::log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2);
1206 return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));
1207 }
1208
1209 // sinh
1210
1211 template <class _Tp>
1212 _LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) {
1213 if (std::isinf(__x.real()) && !std::isfinite(__x.imag()))
1214 return complex<_Tp>(__x.real(), _Tp(NAN));
1215 if (__x.real() == 0 && !std::isfinite(__x.imag()))
1216 return complex<_Tp>(__x.real(), _Tp(NAN));
1217 if (__x.imag() == 0 && !std::isfinite(__x.real()))
1218 return __x;
1219 return complex<_Tp>(std::sinh(__x.real()) * std::cos(__x.imag()), std::cosh(__x.real()) * std::sin(__x.imag()));
1220 }
1221
1222 // cosh
1223
1224 template <class _Tp>
1225 _LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) {
1226 if (std::isinf(__x.real()) && !std::isfinite(__x.imag()))
1227 return complex<_Tp>(std::abs(__x.real()), _Tp(NAN));
1228 if (__x.real() == 0 && !std::isfinite(__x.imag()))
1229 return complex<_Tp>(_Tp(NAN), __x.real());
1230 if (__x.real() == 0 && __x.imag() == 0)
1231 return complex<_Tp>(_Tp(1), __x.imag());
1232 if (__x.imag() == 0 && !std::isfinite(__x.real()))
1233 return complex<_Tp>(std::abs(__x.real()), __x.imag());
1234 return complex<_Tp>(std::cosh(__x.real()) * std::cos(__x.imag()), std::sinh(__x.real()) * std::sin(__x.imag()));
1235 }
1236
1237 // tanh
1238
1239 template <class _Tp>
1240 _LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) {
1241 if (std::isinf(__x.real())) {
1242 if (!std::isfinite(__x.imag()))
1243 return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0));
1244 return complex<_Tp>(std::copysign(_Tp(1), __x.real()), std::copysign(_Tp(0), std::sin(_Tp(2) * __x.imag())));
1245 }
1246 if (std::isnan(__x.real()) && __x.imag() == 0)
1247 return __x;
1248 _Tp __2r(_Tp(2) * __x.real());
1249 _Tp __2i(_Tp(2) * __x.imag());
1250 _Tp __d(std::cosh(__2r) + std::cos(__2i));
1251 _Tp __2rsh(std::sinh(__2r));
1252 if (std::isinf(__2rsh) && std::isinf(__d))
1253 return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1), __2i > _Tp(0) ? _Tp(0) : _Tp(-0.));
1254 return complex<_Tp>(__2rsh / __d, std::sin(__2i) / __d);
1255 }
1256
1257 // asin
1258
1259 template <class _Tp>
1260 _LIBCPP_HIDE_FROM_ABI complex<_Tp> asin(const complex<_Tp>& __x) {
1261 complex<_Tp> __z = std::asinh(complex<_Tp>(-__x.imag(), __x.real()));
1262 return complex<_Tp>(__z.imag(), -__z.real());
1263 }
1264
1265 // acos
1266
1267 template <class _Tp>
1268 _LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) {
1269 const _Tp __pi(atan2(+0., -0.));
1270 if (std::isinf(__x.real())) {
1271 if (std::isnan(__x.imag()))
1272 return complex<_Tp>(__x.imag(), __x.real());
1273 if (std::isinf(__x.imag())) {
1274 if (__x.real() < _Tp(0))
1275 return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
1276 return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag());
1277 }
1278 if (__x.real() < _Tp(0))
1279 return complex<_Tp>(__pi, std::signbit(__x.imag()) ? -__x.real() : __x.real());
1280 return complex<_Tp>(_Tp(0), std::signbit(__x.imag()) ? __x.real() : -__x.real());
1281 }
1282 if (std::isnan(__x.real())) {
1283 if (std::isinf(__x.imag()))
1284 return complex<_Tp>(__x.real(), -__x.imag());
1285 return complex<_Tp>(__x.real(), __x.real());
1286 }
1287 if (std::isinf(__x.imag()))
1288 return complex<_Tp>(__pi / _Tp(2), -__x.imag());
1289 if (__x.real() == 0 && (__x.imag() == 0 || std::isnan(__x.imag())))
1290 return complex<_Tp>(__pi / _Tp(2), -__x.imag());
1291 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));
1292 if (std::signbit(__x.imag()))
1293 return complex<_Tp>(std::abs(__z.imag()), std::abs(__z.real()));
1294 return complex<_Tp>(std::abs(__z.imag()), -std::abs(__z.real()));
1295 }
1296
1297 // atan
1298
1299 template <class _Tp>
1300 _LIBCPP_HIDE_FROM_ABI complex<_Tp> atan(const complex<_Tp>& __x) {
1301 complex<_Tp> __z = std::atanh(complex<_Tp>(-__x.imag(), __x.real()));
1302 return complex<_Tp>(__z.imag(), -__z.real());
1303 }
1304
1305 // sin
1306
1307 template <class _Tp>
1308 _LIBCPP_HIDE_FROM_ABI complex<_Tp> sin(const complex<_Tp>& __x) {
1309 complex<_Tp> __z = std::sinh(complex<_Tp>(-__x.imag(), __x.real()));
1310 return complex<_Tp>(__z.imag(), -__z.real());
1311 }
1312
1313 // cos
1314
1315 template <class _Tp>
1316 inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> cos(const complex<_Tp>& __x) {
1317 return std::cosh(complex<_Tp>(-__x.imag(), __x.real()));
1318 }
1319
1320 // tan
1321
1322 template <class _Tp>
1323 _LIBCPP_HIDE_FROM_ABI complex<_Tp> tan(const complex<_Tp>& __x) {
1324 complex<_Tp> __z = std::tanh(complex<_Tp>(-__x.imag(), __x.real()));
1325 return complex<_Tp>(__z.imag(), -__z.real());
1326 }
1327
1328 # if _LIBCPP_HAS_LOCALIZATION
1329 template <class _Tp, class _CharT, class _Traits>
1330 _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
1331 operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) {
1332 if (__is.good()) {
1333 std::ws(__is);
1334 if (__is.peek() == _CharT('(')) {
1335 __is.get();
1336 _Tp __r;
1337 __is >> __r;
1338 if (!__is.fail()) {
1339 std::ws(__is);
1340 _CharT __c = __is.peek();
1341 if (__c == _CharT(',')) {
1342 __is.get();
1343 _Tp __i;
1344 __is >> __i;
1345 if (!__is.fail()) {
1346 std::ws(__is);
1347 __c = __is.peek();
1348 if (__c == _CharT(')')) {
1349 __is.get();
1350 __x = complex<_Tp>(__r, __i);
1351 } else
1352 __is.setstate(__is.failbit);
1353 } else
1354 __is.setstate(__is.failbit);
1355 } else if (__c == _CharT(')')) {
1356 __is.get();
1357 __x = complex<_Tp>(__r, _Tp(0));
1358 } else
1359 __is.setstate(__is.failbit);
1360 } else
1361 __is.setstate(__is.failbit);
1362 } else {
1363 _Tp __r;
1364 __is >> __r;
1365 if (!__is.fail())
1366 __x = complex<_Tp>(__r, _Tp(0));
1367 else
1368 __is.setstate(__is.failbit);
1369 }
1370 } else
1371 __is.setstate(__is.failbit);
1372 return __is;
1373 }
1374
1375 template <class _Tp, class _CharT, class _Traits>
1376 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
1377 operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) {
1378 basic_ostringstream<_CharT, _Traits> __s;
1379 __s.flags(__os.flags());
1380 __s.imbue(__os.getloc());
1381 __s.precision(__os.precision());
1382 __s << '(' << __x.real() << ',' << __x.imag() << ')';
1383 return __os << __s.str();
1384 }
1385 # endif // _LIBCPP_HAS_LOCALIZATION
1386
1387 # if _LIBCPP_STD_VER >= 26
1388
1389 // [complex.tuple], tuple interface
1390
1391 template <class _Tp>
1392 struct tuple_size<complex<_Tp>> : integral_constant<size_t, 2> {};
1393
1394 template <size_t _Ip, class _Tp>
1395 struct tuple_element<_Ip, complex<_Tp>> {
1396 static_assert(_Ip < 2, "Index value is out of range.");
1397 using type = _Tp;
1398 };
1399
1400 template <size_t _Ip, class _Xp>
1401 _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>& __z) noexcept {
1402 static_assert(_Ip < 2, "Index value is out of range.");
1403 if constexpr (_Ip == 0) {
1404 return __z.__re_;
1405 } else {
1406 return __z.__im_;
1407 }
1408 }
1409
1410 template <size_t _Ip, class _Xp>
1411 _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&& __z) noexcept {
1412 static_assert(_Ip < 2, "Index value is out of range.");
1413 if constexpr (_Ip == 0) {
1414 return std::move(__z.__re_);
1415 } else {
1416 return std::move(__z.__im_);
1417 }
1418 }
1419
1420 template <size_t _Ip, class _Xp>
1421 _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>& __z) noexcept {
1422 static_assert(_Ip < 2, "Index value is out of range.");
1423 if constexpr (_Ip == 0) {
1424 return __z.__re_;
1425 } else {
1426 return __z.__im_;
1427 }
1428 }
1429
1430 template <size_t _Ip, class _Xp>
1431 _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&& __z) noexcept {
1432 static_assert(_Ip < 2, "Index value is out of range.");
1433 if constexpr (_Ip == 0) {
1434 return std::move(__z.__re_);
1435 } else {
1436 return std::move(__z.__im_);
1437 }
1438 }
1439
1440 # endif // _LIBCPP_STD_VER >= 26
1441
1442 # if _LIBCPP_STD_VER >= 14
1443 // Literal suffix for complex number literals [complex.literals]
1444 inline namespace literals {
1445 inline namespace complex_literals {
1446 _LIBCPP_HIDE_FROM_ABI inline constexpr complex<long double> operator""il(long double __im) { return {0.0l, __im}; }
1447
1448 _LIBCPP_HIDE_FROM_ABI inline constexpr complex<long double> operator""il(unsigned long long __im) {
1449 return {0.0l, static_cast<long double>(__im)};
1450 }
1451
1452 _LIBCPP_HIDE_FROM_ABI inline constexpr complex<double> operator""i(long double __im) {
1453 return {0.0, static_cast<double>(__im)};
1454 }
1455
1456 _LIBCPP_HIDE_FROM_ABI inline constexpr complex<double> operator""i(unsigned long long __im) {
1457 return {0.0, static_cast<double>(__im)};
1458 }
1459
1460 _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(long double __im) {
1461 return {0.0f, static_cast<float>(__im)};
1462 }
1463
1464 _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(unsigned long long __im) {
1465 return {0.0f, static_cast<float>(__im)};
1466 }
1467 } // namespace complex_literals
1468 } // namespace literals
1469 # endif
1470
1471 _LIBCPP_END_NAMESPACE_STD
1472
1473 _LIBCPP_POP_MACROS
1474
1475 # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1476 # include <iosfwd>
1477 # include <stdexcept>
1478 # include <type_traits>
1479 # endif
1480 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
1481
1482 #endif // _LIBCPP_COMPLEX