Back to home page

EIC code displayed by LXR

 
 

    


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