ê*ÏG±mà ÏG±mselinuxunconfined_u:object_r:file_t:s0late complex<_Tp>& complex<_Tp>::operator/=(const _Tp& __t) { _M_real /= __t; _M_imag /= __t; return *this; } template template complex<_Tp>& complex<_Tp>::operator=(const complex<_Up>& __z) { _M_real = __z.real(); _M_imag = __z.imag(); return *this; } // 26.2.5/9 template template complex<_Tp>& complex<_Tp>::operator+=(const complex<_Up>& __z) { _M_real += __z.real(); _M_imag += __z.imag(); return *this; } // 26.2.5/11 template template complex<_Tp>& complex<_Tp>::operator-=(const complex<_Up>& __z) { _M_real -= __z.real(); _M_imag -= __z.imag(); return *this; } // 26.2.5/13 // XXX: This is a grammar school implementation. template template complex<_Tp>& complex<_Tp>::operator*=(const complex<_Up>& __z) { const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag(); _M_imag = _M_real * __z.imag() + _M_imag * __z.real(); _M_real = __r; return *this; } // 26.2.5/15 // XXX: This is a grammar school implementation. template template complex<_Tp>& complex<_Tp>::operator/=(const complex<_Up>& __z) { const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag(); const _Tp __n = std::norm(__z); _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n; _M_real = __r / __n; return *this; } template inline const complex<_Tp>& complex<_Tp>::__rep() const { return *this; } // Operators: //@{ /// Return new complex value @a x plus @a y. template inline complex<_Tp> operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __x; __r += __y; return __r; } template inline complex<_Tp> operator+(const complex<_Tp>& __x, const _Tp& __y) { complex<_Tp> __r = __x; __r.real() += __y; return __r; } template inline complex<_Tp> operator+(const _Tp& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __y; __r.real() += __x; return __r; } //@} //@{ /// Return new complex value @a x minus @a y. template inline complex<_Tp> operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __x; __r -= __y; return __r; } template inline complex<_Tp> operator-(const complex<_Tp>& __x, const _Tp& __y) { complex<_Tp> __r = __x; __r.real() -= __y; return __r; } template inline complex<_Tp> operator-(const _Tp& __x, const complex<_Tp>& __y) { complex<_Tp> __r(__x, -__y.imag()); __r.real() -= __y.real(); return __r; } //@} //@{ /// Return new complex value @a x times @a y. template inline complex<_Tp> operator*(const complex<_Tp>& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __x; __r *= __y; return __r; } template inline complex<_Tp> operator*(const complex<_Tp>& __x, const _Tp& __y) { complex<_Tp> __r = __x; __r *= __y; return __r; } template inline complex<_Tp> operator*(const _Tp& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __y; __r *= __x; return __r; } //@} //@{ /// Return new complex value @a x divided by @a y. template inline complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __x; __r /= __y; return __r; } template inline complex<_Tp> operator/(const complex<_Tp>& __x, const _Tp& __y) { complex<_Tp> __r = __x; __r /= __y; return _Ò!Ó!Ô!Õ!Ö!×!Ø!Ù!Ú!Û!Ü!Ý!Þ!ß!à!á!â!ã!ä!å!æ!ç!è!é!ê!ë!ì!í!î!ï!ð!_r; } template inline complex<_Tp> operator/(const _Tp& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __x; __r /= __y; return __r; } //@} /// Return @a x. template inline complex<_Tp> operator+(const complex<_Tp>& __x) { return __x; } /// Return complex negation of @a x. template inline complex<_Tp> operator-(const complex<_Tp>& __x) { return complex<_Tp>(-__x.real(), -__x.imag()); } //@{ /// Return true if @a x is equal to @a y. template inline bool operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) { return __x.real() == __y.real() && __x.imag() == __y.imag(); } template inline bool operator==(const complex<_Tp>& __x, const _Tp& __y) { return __x.real() == __y && __x.imag() == _Tp(); } template inline bool operator==(const _Tp& __x, const complex<_Tp>& __y) { return __x == __y.real() && _Tp() == __y.imag(); } //@} //@{ /// Return false if @a x is equal to @a y. template inline bool operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) { return __x.real() != __y.real() || __x.imag() != __y.imag(); } template inline bool operator!=(const complex<_Tp>& __x, const _Tp& __y) { return __x.real() != __y || __x.imag() != _Tp(); } template inline bool operator!=(const _Tp& __x, const complex<_Tp>& __y) { return __x != __y.real() || _Tp() != __y.imag(); } //@} /// Extraction operator for complex values. template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) { _Tp __re_x, __im_x; _CharT __ch; __is >> __ch; if (__ch == '(') { __is >> __re_x >> __ch; if (__ch == ',') { __is >> __im_x >> __ch; if (__ch == ')') __x = complex<_Tp>(__re_x, __im_x); else __is.setstate(ios_base::failbit); } else if (__ch == ')') __x = __re_x; else __is.setstate(ios_base::failbit); } else { __is.putback(__ch); __is >> __re_x; __x = __re_x; } return __is; } /// Insertion operator for complex values. template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) { basic_ostringstream<_CharT, _Traits> __s; __s.flags(__os.flags()); __s.imbue(__os.getloc()); __s.precision(__os.precision()); __s << '(' << __x.real() << ',' << __x.imag() << ')'; return __os << __s.str(); } // Values template inline _Tp& real(complex<_Tp>& __z) { return __z.real(); } template inline const _Tp& real(const complex<_Tp>& __z) { return __z.real(); } template inline _Tp& imag(complex<_Tp>& __z) { return __z.imag(); } template inline const _Tp& imag(const complex<_Tp>& __z) { return __z.imag(); } // 26.2.7/3 abs(__z): Returns the magnitude of __z. template inline _Tp __complex_abs(const complex<_Tp>& __z) { _Tp __x = __z.real(); _Tp __y = __z.imag(); const _Tp __s = std::max(abs(__x), abs(__y)); if (__s == _Tp()) // well ... return __s; __x /= __s; __y /= __s; return __s * sqrt(__x * __x + __y * __y); } #if _GLIBCXX_USE_C99_COMPLEX inline float __complex_abs(__complex__ float __z) { return __builtin_cabsf(__z); } inline double __complex_abs(__complex__ double __z) { return __builtin_cabs(__z); } inline long double __complex_abs(const __complex__ long double& __z) { return __builtin_cabsl(__z); } template inline _Tp abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); } #else template inline _Tp abs(const complex<_Tp>& __z) { return __complex_abs(__z); } #endif // 26.2.7/4: arg(__z): Returns the phase angle of __z. template inline _Tp __complex_arg(const complex<_Tp>& __z) { return atan2(__z.imag(), __z.real()); } #if _GLIBCXX_USE_C99_COMPLEX inline float __complex_arg(__complex__ float __z) { return __builtin_cargf(__z); } inline double __complex_arg(__complex__ double __z) { return __builtin_carg(__z); } inline long double __complex_arg(const __complex__ long double& __z) { return __builtin_cargl(__z); } template inline _Tp arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); } #else template inline _Tp arg(const complex<_Tp>& __z) { return __complex_arg(__z); } #endif // 26.2.7/5: norm(__z) returns the squared magnitude of __z. // As defined, norm() is -not- a norm is the common mathematical // sens used in numerics. The helper class _Norm_helper<> tries to // distinguish between builtin floating point and the rest, so as // to deliver an answer as close as possible to the real value. template struct _Norm_helper { template static inline _Tp _S_do_it(const complex<_Tp>& __z) { const _Tp __x = __z.real(); const _Tp __y = __z.imag(); return __x * __x + __y * __y; } }; template<> struct _Norm_helper { template static inline _Tp _S_do_it(const complex<_Tp>& __z) { _Tp __res = std::abs(__z); return __res * __res; } }; template inline _Tp norm(const complex<_Tp>& __z) { return _Norm_helper<__is_floating<_Tp>::__value && !_GLIBCXX_FAST_MATH>::_S_do_it(__z); } template inline complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta) { return complex<_Tp>(__rho * cos(__theta), __rho * sin(__theta)); } template inline complex<_Tp> conj(const complex<_Tp>& __z) { return complex<_Tp>(__z.real(), -__z.imag()); } // Transcendentals // 26.2.8/1 cos(__z): Returns the cosine of __z. template inline complex<_Tp> __complex_cos(const complex<_Tp>& __z) { const _Tp __x = __z.real(); const _Tp __y = __z.imag(); return complex<_Tp>(cos(__x) * cosh(__y), -sin(__x) * sinh(__y)); } #if _GLIBCXX_USE_C99_COMPLEX inline __complex__ float __complex_cos(__complex__ float __z) { return __builtin_ccosf(__z); } inline __complex__ double __complex_cos(__complex__ double __z) { return __builtin_ccos(__z); } inline __complex__ long double __complex_cos(const __complex__ long double& __z) { return __builtin_ccosl(__z); } template inline complex<_Tp> cos(const complex<_Tp>& __z) { return __complex_cos(__z.__rep()); } #else template inline complex<_Tp> cos(const complex<_Tp>& __z) { return __complex_cos(__z); } #endif // 26.2.8/2 cosh(__z): Returns the hyperbolic cosine of __z. template inline complex<_Tp> __complex_cosh(const complex<_Tp>& __z) { const _Tp __x = __z.real(); const _Tp __y = __z.imag(); return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y)); } #if _GLIBCXX_USE_C99_COMPLEX inline __complex__ float __complex_cosh(__complex__ float __z) { return __builtin_ccoshf(__z); } inline __complex__ double __complex_cosh(__complex__ double __z) { return __builtin_ccosh(__z); } inline __complex__ long double __complex_cosh(const __complex__ long double& __z) { return __builtin_ccoshl(__z); } template inline complex<_Tp> cosh(const complex<_Tp>& __z) { return __complex_cosh(__z.__rep()); } #else template inline complex<_Tp> cosh(const complex<_Tp>& __z) { return __complex_cosh(__z); } #endif // 26.2.8/3 exp(__z): Returns the complex base e exponential of x template inline complex<_Tp> __complex_exp(const complex<_Tp>& __z) { return std::polar(exp(__z.real()), __z.imag()); } #if _GLIBCXX_USE_C99_COMPLEX inline __complex__ float __complex_exp(__complex__ float __z) { return __builtin_cexpf(__z); } inline __complex__ double __complex_exp(__complex__ double __z) { return __builtin_cexp(__z); } inline __complex__ long double __complex_exp(const __complex__ long double& __z) { return __builtin_cexpl(__z); } template inline complex<_Tp> exp(const complex<_Tp>& __z) { return __complex_exp(__z.__rep()); } #else template inline complex<_Tp> exp(const complex<_Tp>& __z) { return __complex_exp(__z); } #endif // 26.2.8/5 log(__z): Returns the natural complex logarithm of __z. // The branch cut is along the negative axis. template inline complex<_Tp> __complex_log(const complex<_Tp>& __z) { return complex<_Tp>(log(std::abs(__z)), std::arg(__z)); } #if _GLIBCXX_USE_C99_COMPLEX inline __complex__ float __complex_log(__complex__ float __z) { return __builtin_clogf(__z); } inline __complex__ double __complex_log(__complex__ double __z) { return __builtin_clog(__z); } inline __complex__ long double __complex_log(const __complex__ long double& __z) { return __builtin_clogl(__z); } template inline complex<_Tp> log(const complex<_Tp>& __z) { return __complex_log(__z.__rep()); } #else template inline complex<_Tp> log(const complex<_Tp>& __z) { return __complex_log(__z); } #endif template inline complex<_Tp> log10(const complex<_Tp>& __z) { return std::log(__z) / log(_Tp(10.0)); } // 26.2.8/10 sin(__z): Returns the sine of __z. template inline complex<_Tp> __complex_sin(const complex<_Tp>& __z) { const _Tp __x = __z.real(); const _Tp __y = __z.imag(); return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y)); } #if _GLIBCXX_USE_C99_COMPLEX inline __complex__ float __complex_sin(__complex__ float __z) { return __builtin_csinf(__z); } inline __complex__ double __complex_sin(__complex__ double __z) { return __builtin_csin(__z); } inline __complex__ long double __complex_sin(const __complex__ long double& __z) { return __builtin_csinl(__z); } template inline complex<_Tp> sin(const complex<_Tp>& __z) { return __complex_sin(__z.__rep()); } #else template inline complex<_Tp> sin(const complex<_Tp>& __z) { return __complex_sin(__z); } #endif // 26.2.8/11 sinh(__z): Returns the hyperbolic sine of __z. template inline complex<_Tp> __complex_sinh(const complex<_Tp>& __z) { const _Tp __x = __z.real(); const _Tp __y = __z.imag(); return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y)); } #if _GLIBCXX_USE_C99_COMPLEX inline __complex__ float __complex_sinh(__complex__ float __z) { return __builtin_csinhf(__z); } inline __complex__ double __complex_sinh(__complex__ double __z) { return __builtin_csinh(__z); } inline __complex__ long double __complex_sinh(const __complex__ long double& __z) { return __builtin_csinhl(__z); } template inline complex<_Tp> sinh(const complex<_Tp>& __z) { return __complex_sinh(__z.__rep()); } #else template inline complex<_Tp> sinh(const complex<_Tp>& __z) { return __complex_sinh(__z); } #endif // 26.2.8/13 sqrt(__z): Returns the complex square root of __z. // The branch cut is on the negative axis. template complex<_Tp> __complex_sqrt(const complex<_Tp>& __z) { _Tp __x = __z.real(); _Tp __y = __z.imag(); if (__x == _Tp()) { _Tp __t = sqrt(abs(__y) / 2); return complex<_Tp>(__t, __y < _Tp() ? -__t : __t); } else { _Tp __t = sqrt(2 * (std::abs(__z) + abs(__x))); _Tp __u = __t / 2; return __x > _Tp() ? complex<_Tp>(__u, __y / __t) : complex<_Tp>(abs(__y) / __t, __y < _Tp() ? -__u : __u); } } #if _GLIBCXX_USE_C99_COMPLEX inline __complex__ float __complex_sqrt(__complex__ float __z) { return __builtin_csqrtf(__z); } inline __complex__ double __complex_sqrt(__complex__ double __z) { return __builtin_csqrt(__z); } inline __complex__ long double __complex_sqrt(const __complex__ long double& __z) { return __builtin_csqrtl(__z); } template inline complex<_Tp> sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); } #else template inline complex<_Tp> sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z); } #endif // 26.2.8/14 tan(__z): Return the complex tangent of __z. template inline complex<_Tp> __complex_tan(const complex<_Tp>& __z) { return std::sin(__z) / std::cos(__z); } #if _GLIBCXX_USE_C99_COMPLEX inline __complex__ float __complex_tan(__complex__ float __z) { return __builtin_ctanf(__z); } inline __complex__ double __complex_tan(__complex__ double __z) { return __builtin_ctan(__z); } inline __complex__ long double __complex_tan(const __complex__ long double& __z) { return __builtin_ctanl(__z); } template inline complex<_Tp> tan(const complex<_Tp>& __z) { return __complex_tan(__z.__rep()); } #else template inline complex<_Tp> tan(const complex<_Tp>& __z) { return __complex_tan(__z); } #endif // 26.2.8/15 tanh(__z): Returns the hyperbolic tangent of __z. template inline complex<_Tp> __complex_tanh(const complex<_Tp>& __z) { return std::sinh(__z) / std::cosh(__z); } #if _GLIBCXX_USE_C99_COMPLEX inline __complex__ float __complex_tanh(__complex__ float __z) { return __builtin_ctanhf(__z); } inline __complex__ double __complex_tanh(__complex__ double __z) { return __builtin_ctanh(__z); } inline __complex__ long double __complex_tanh(const __complex__ long double& __z) { return __builtin_ctanhl(__z); } template inline complex<_Tp> tanh(const complex<_Tp>& __z) { return __complex_tanh(__z.__rep()); } #else template inline complex<_Tp> tanh(const complex<_Tp>& __z) { return __complex_tanh(__z); } #endif // 26.2.8/9 pow(__x, __y): Returns the complex power base of __x // raised to the __y-th power. The branch // cut is on the negative axis. template inline complex<_Tp> pow(const complex<_Tp>& __z, int __n) { return std::__pow_helper(__z, __n); } template complex<_Tp> pow(const complex<_Tp>& __x, const _Tp& __y) { #ifndef _GLIBCXX_USE_C99_COMPLEX if (__x == _Tp()) return _Tp(); #endif if (__x.imag() == _Tp() && __x.real() > _Tp()) return pow(__x.real(), __y); complex<_Tp> __t = std::log(__x); return std::polar(exp(__y * __t.real()), __y * __t.imag()); } template inline complex<_Tp> __complex_pow(const complex<_Tp>& __x, const complex<_Tp>& __y) { return __x == _Tp() ? _Tp() : std::exp(__y * std::log(__x)); } #if _GLIBCXX_USE_C99_COMPLEX inline __complex__ float __complex_pow(__complex__ float __x, __complex__ float __y) { return __builtin_cpowf(__x, __y); } inline __complex__ double __complex_pow(__complex__ double __x, __complex__ double __y) { return __builtin_cpow(__x, __y); } inline __complex__ long double __complex_pow(const __complex__ long double& __x, const __complex__ long double& __y) { return __builtin_cpowl(__x, __y); } template inline complex<_Tp> pow(const complex<_Tp>& __x, const complex<_Tp>& __y) { return __complex_pow(__x.__rep(), __y.__rep()); } #else template inline complex<_Tp> pow(const complex<_Tp>& __x, const complex<_Tp>& __y) { return __complex_pow(__x, __y); } #endif template inline complex<_Tp> pow(const _Tp& __x, const complex<_Tp>& __y) { return __x > _Tp() ? std::polar(pow(__x, __y.real()), __y.imag() * log(__x)) : std::pow(complex<_Tp>(__x, _Tp()), __y); } // 26.2.3 complex specializations // complex specialization template<> struct complex { typedef float value_type; typedef __complex__ float _ComplexT; complex(_ComplexT __z) : _M_value(__z) { } complex(float = 0.0f, float = 0.0f); explicit complex(const complex&); explicit complex(const complex&); float& real(); const float& real() const; float& imag(); const float& imag() const; complex& operator=(float); complex& operator+=(float); complex& operator-=(float); complex& operator*=(float); complex& operator/=(float); // Let the compiler synthesize the copy and assignment // operator. It always does a pretty good job. // complex& operator= (const complex&); template complex&operator=(const complex<_Tp>&); template complex& operator+=(const complex<_Tp>&); template complex& operator-=(const complex<_Tp>&); template complex& operator*=(const complex<_Tp>&); template complex&operator/=(const complex<_Tp>&); const _ComplexT& __rep() const { return _M_value; } private: _ComplexT _M_value; }; inline float& complex::real() { return __real__ _M_value; } inline const float& complex::real() const { return __real__ _M_value; } inline float& complex::imag() { return __imag__ _M_value; } inline const float& complex::imag() const { return __imag__ _M_value; } inline complex::complex(float __r, float __i) { __real__ _M_value = __r; __imag__ _M_value = __i; } inline complex& complex::operator=(float __f) { __real__ _M_value = __f; __imag__ _M_value = 0.0f; return *this; } inline complex& complex::operator+=(float __f) { __real__ _M_value += __f; return *this; } inline complex& complex::operator-=(float __f) { __real__ _M_value -= __f; return *this; } inline complex& complex::operator*=(float __f) { _M_value *= __f; return *this; } inline complex& complex::operator/=(float __f) { _M_value /= __f; return *this; } template inline complex& complex::operator=(const complex<_Tp>& __z) { __real__ _M_value = __z.real(); __imag__ _M_value = __z.imag(); return *this; } template inline complex& complex::operator+=(const complex<_Tp>& __z) { __real__ _M_value += __z.real(); __imag__ _M_value += __z.imag(); return *this; } template inline complex& complex::operator-=(const complex<_Tp>& __z) { __real__ _M_value -= __z.real(); __imag__ _M_value -= __z.imag(); return *this; } template inline complex& complex::operator*=(const complex<_Tp>& __z) { _ComplexT __t; __real__ __t = __z.real(); __imag__ __t = __z.imag(); _M_value *= __t; return *this; } template inline complex& complex::operator/=(const complex<_Tp>& __z) { _ComplexT __t; __real__ __t = __z.real(); __imag__ __t = __z.imag(); _M_value /= __t; return *this; } // 26.2.3 complex specializations // complex specialization template<> struct complex { typedef double value_type; typedef __complex__ double _ComplexT; complex(_ComplexT __z) : _M_value(__z) { } complex(double = 0.0, double = 0.0); complex(const complex&); explicit complex(const complex&); double& real(); const double& real() const; double& imag(); const double& imag() const; complex& operator=(double); complex& operator+=(double); complex& operator-=(double); complex& operator*=(double); complex& operator/=(double); // The compiler will synthesize this, efficiently. // complex& operator= (const complex&); template complex& operator=(const complex<_Tp>&); template complex& operator+=(const complex<_Tp>&); template complex& operator-=(const complex<_Tp>&); template complex& operator*=(const complex<_Tp>&); template complex& operator/=(const complex<_Tp>&); const _ComplexT& __rep() const { return _M_value; } private: _ComplexT _M_value; }; inline double& complex::real() { return __real__ _M_value; } inline const double& complex::real() const { return __real__ _M_value; } inline double& complex::imag() { return __imag__ _M_value; } inline const double& complex::imag() const { return __imag__ _M_value; } inline complex::complex(double __r, double __i) { __real__ _M_value = __r; __imag__ _M_value = __i; } inline complex& complex::operator=(double __d) { __real__ _M_value = __d; __imag__ _M_value = 0.0; return *this; } inline complex& complex::operator+=(double __d) { __real__ _M_value += __d; return *this; } inline complex& complex::operator-=(double __d) { __real__ _M_value -= __d; return *this; } inline complex& complex::operator*=(double __d) { _M_value *= __d; return *this; } inline complex& complex::operator/=(double __d) { _M_value /= __d; return *this; } template inline complex& complex::operator=(const complex<_Tp>& __z) { __real__ _M_value = __z.real(); __imag__ _M_value = __z.imag(); return *this; } template inline complex& complex::operator+=(const complex<_Tp>& __z) { __real__ _M_value += __z.real(); __imag__ _M_value += __z.imag(); return *this; } template inline complex& complex::operator-=(const complex<_Tp>& __z) { __real__ _M_value -= __z.real(); __imag__ _M_value -= __z.imag(); return *this; } template inline complex& complex::operator*=(const complex<_Tp>& __z) { _ComplexT __t; __real__ __t = __z.real(); __imag__ __t = __z.imag(); _M_value *= __t; return *this; } template inline complex& complex::operator/=(const complex<_Tp>& __z) { _ComplexT __t; __real__ __t = __z.real(); __imag__ __t = __z.imag(); _M_value /= __t; return *this; } // 26.2.3 complex specializations // complex specialization template<> struct complex { typedef long double value_type; typedef __complex__ long double _ComplexT; complex(_ComplexT __z) : _M_value(__z) { } complex(long double = 0.0L, long double = 0.0L); complex(const complex&); complex(const complex&); long double& real(); const long double& real() const; long double& imag(); const long double& imag() const; complex& operator= (long double); complex& operator+= (long double); complex& operator-= (long double); complex& operator*= (long double); complex& operator/= (long double); // The compiler knows how to do this efficiently // complex& operator= (const complex&); template complex& operator=(const complex<_Tp>&); template complex& operator+=(const complex<_Tp>&); template complex& operator-=(const complex<_Tp>&); template complex& operator*=(const complex<_Tp>&); template complex& operator/=(const complex<_Tp>&); const _ComplexT& __rep() const { return _M_value; } private: _ComplexT _M_value; }; inline complex::complex(long double __r, long double __i) { __real__ _M_value = __r; __imag__ _M_value = __i; } inline long double& complex::real() { return __real__ _M_value; } inline const long double& complex::real() const { return __real__ _M_value; } inline long double& complex::imag() { return __imag__ _M_value; } inline const long double& complex::imag() const { return __imag__ _M_value; } inline complex& complex::operator=(long double __r) { __real__ _M_value = __r; __imag__ _M_value = 0.0L; return *this; } inline complex& complex::operator+=(long double __r) { __real__ _M_value += __r; return *this; } inline complex& complex::operator-=(long double __r) { __real__ _M_value -= __r; return *this; } inline complex& complex::operator*=(long double __r) { _M_value *= __r; return *this; } inline complex& complex::operator/=(long double __r) { _M_value /= __r; return *this; } template inline complex& complex::operator=(const complex<_Tp>& __z) { __real__ _M_value = __z.real(); __imag__ _M_value = __z.imag(); return *this; } template inline complex& complex::operator+=(const complex<_Tp>& __z) { __real__ _M_value += __z.real(); __imag__ _M_value += __z.imag(); return *this; } template inline complex& complex::operator-=(const complex<_Tp>& __z) { __real__ _M_value -= __z.real(); __imag__ _M_value -= __z.imag(); return *this; } template inline complex& complex::operator*=(const complex<_Tp>& __z) { _ComplexT __t; __real__ __t = __z.real(); __imag__ __t = __z.imag(); _M_value *= __t; return *this; } template inline complex& complex::operator/=(const complex<_Tp>& __z) { _ComplexT __t; __real__ __t = __z.real(); __imag__ __t = __z.imag(); _M_value /= __t; return *this; } // These bits have to be at the end of this file, so that the // specializations have all been defined. // ??? No, they have to be there because of compiler limitation at // inlining. It suffices that class specializations be defined. inline complex::complex(const complex& __z) : _M_value(__z.__rep()) { } inline complex::complex(const complex& __z) : _M_value(__z.__rep()) { } inline complex::complex(const complex& __z) : _M_value(__z.__rep()) { } inline complex::complex(const complex& __z) : _M_value(__z.__rep()) { } inline complex::complex(const complex& __z) : _M_value(__z.__rep()) { } inline complex::complex(const complex& __z) : _M_value(__z.__rep()) { } // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. #if _GLIBCXX_EXTERN_TEMPLATE extern template istream& operator>>(istream&, complex&); extern template ostream& operator<<(ostream&, const complex&); extern template istream& operator>>(istream&, complex&); extern template ostream& operator<<(ostream&, const complex&); extern template istream& operator>>(istream&, complex&); extern template ostream& operator<<(ostream&, const complex&); #ifdef _GLIBCXX_USE_WCHAR_T extern template wistream& operator>>(wistream&, complex&); extern template wostream& operator<<(wostream&, const complex&); extern template wistream& operator>>(wistream&, complex&); extern template wostream& operator<<(wostream&, const complex&); extern template wistream& operator>>(wistream&, complex&); extern template wostream& operator<<(wostream&, const complex&); #endif #endif _GLIBCXX_END_NAMESPACE _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) // See ext/type_traits.h for the primary template. template struct __promote_2, _Up> { public: typedef std::complex::__type> __type; }; template struct __promote_2<_Tp, std::complex<_Up> > { public: typedef std::complex::__type> __type; }; template struct __promote_2, std::complex<_Up> > { public: typedef std::complex::__type> __type; }; _GLIBCXX_END_NAMESPACE #ifdef __GXX_EXPERIMENTAL_CXX0X__ # if defined(_GLIBCXX_INCLUDE_AS_TR1) # error C++0x header cannot be included from TR1 header # endif # if defined(_GLIBCXX_INCLUDE_AS_CXX0X) # include # else # define _GLIBCXX_INCLUDE_AS_CXX0X # define _GLIBCXX_BEGIN_NAMESPACE_TR1 # define _GLIBCXX_END_NAMESPACE_TR1 # define _GLIBCXX_TR1 # include # undef _GLIBCXX_TR1 # undef _GLIBCXX_END_NAMESPACE_TR1 # undef _GLIBCXX_BEGIN_NAMESPACE_TR1 # undef _GLIBCXX_INCLUDE_AS_CXX0X # endif #endif #endif /* _GLIBCXX_COMPLEX */ // The -*- C++ -*- forwarding header. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, // 2006, 2007, 2008 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 51 Franklin Street, Fifth Floor, // Boston, MA 02110-1301, USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file cerrno * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c errno.h, * and its contents are (mostly) the same as that header, but are all * contained in the namespace @c std (except for names which are defined * as macros in C). */ // // ISO C++ 14882: 19.3 Error numbers // #pragma GCC system_header #include #ifndef _GLIBCXX_CERRNO #define _GLIBCXX_CERRNO 1 // Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 #ifndef errno #define errno errno #endif #endif // -*- C++ -*- forwarding header. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, // 2006, 2007, 2008 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file include/cctype * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c ctype.h, * and its contents are (mostly) the same as that header, but are all * contained in the namespace @c std (except for names which are defined * as macros in C). */ // // ISO C++ 14882: // #pragma GCC system_header #include #include #ifndef _GLIBCXX_CCTYPE #define _GLIBCXX_CCTYPE 1 // Get rid of those macros defined in in lieu of real functions. #undef isalnum #undef isalpha #undef iscntrl #undef isdigit #undef isgraph #undef islower #undef isprint #undef ispunct #undef isspace #undef isupper #undef isxdigit #undef tolower #undef toupper _GLIBCXX_BEGIN_NAMESPACE(std) using ::isalnum; using ::isalpha; using ::iscntrl; using ::isdigit; using ::isgraph; using ::islower; using ::isprint; using ::ispunct; using ::isspace; using ::isupper; using ::isxdigit; using ::tolower; using ::toupper; _GLIBCXX_END_NAMESPACE #ifdef __GXX_EXPERIMENTAL_CXX0X__ # if defined(_GLIBCXX_INCLUDE_AS_TR1) # error C++0x header cannot be included from TR1 header # endif # if defined(_GLIBCXX_INCLUDE_AS_CXX0X) # include # else # define _GLIBCXX_INCLUDE_AS_CXX0X # define _GLIBCXX_BEGIN_NAMESPACE_TR1 # define _GLIBCXX_END_NAMESPACE_TR1 # define _GLIBCXX_TR1 # include # undef _GLIBCXX_TR1 # undef _GLIBCXX_END_NAMESPACE_TR1 # undef _GLIBCXX_BEGIN_NAMESPACE_TR1 # undef _GLIBCXX_INCLUDE_AS_CXX0X # endif #endif #endif " . ..#string$ multimap.h%debug.h&safe_iterator.h'safe_sequence.h( formatter.h)set.h*map.h+ unordered_set,macros.h- list.bitset/deque0 unordered_map1 map2 set3 multiset.h4 functions.h5 safe_base.h6safe_association.h7vector8dsafe_iterator.tcc// Debugging string implementation -*- C++ -*- // Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file debug/string * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_STRING #define _GLIBCXX_DEBUG_STRING 1 #include #include #include namespace __gnu_debug { template, typename _Allocator = std::allocator<_CharT> > class basic_string : public std::basic_string<_CharT, _Traits, _Allocator>, public __gnu_debug::_Safe_sequence > { typedef std::basic_string<_CharT, _Traits, _Allocator> _Base; typedef __gnu_debug::_Safe_sequence _Safe_base; public: // types: typedef _Traits traits_type; typedef typename _Traits::char_type value_type; typedef _Allocator allocator_type; typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef typename _Base::pointer pointer; typedef typename _Base::const_pointer const_pointer; typedef __gnu_debug::_Safe_iterator iterator; typedef __gnu_debug::_Safe_iterator const_iterator; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; using _Base::npos; // 21.3.1 construct/copy/destroy: explicit basic_string(const _Allocator& __a = _Allocator()) : _Base(__a) { } // Provides conversion from a release-mode string to a debug-mode string basic_string(const _Base& __base) : _Base(__base), _Safe_base() { } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 42. string ctors specify wrong default allocator basic_string(const basic_string& __str) : _Base(__str, 0, _Base::npos, __str.get_allocator()), _Safe_base() { } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 42. string ctors specify wrong default allocator basic_string(const basic_string& __str, size_type __pos, size_type __n = _Base::npos, const _Allocator& __a = _Allocator()) : _Base(__str, __pos, __n, __a) { } basic_string(const _CharT* __s, size_type __n, const _Allocator& __a = _Allocator()) : _Base(__gnu_debug::__check_string(__s, __n), __n, __a) { } basic_string(const _CharT* __s, const _Allocator& __a = _Allocator()) : _Base(__gnu_debug::__check_string(__s), __a) { this->assign(__s); } basic_string(size_type __n, _CharT __c, const _Allocator& __a = _Allocator()) : _Base(__n, __c, __a) { } template basic_string(_InputIterator __begin, _InputIterator __end, const _Allocator& __a = _Allocator()) : _Base(__gnu_debug::__check_valid_range(__begin, __end), __end, __a) { } ~basic_string() { } basic_string& operator=(const basic_string& __str) { *static_cast<_Base*>(this) = __str; this->_M_invalidate_all(); return *this; } basic_string& operator=(const _CharT* __s) { __glibcxx_check_string(__s); *static_cast<_Base*>(this) = __s; this->_M_invalidate_all(); return *this; } basic_string& operator=(_CharT __c) { *static_cast<_Base*>(this) = __c; this->_M_invalidate_all(); return *this; } // 21.3.2 iterators: iterator begin() { return iterator(_Base::begin(), this); } const_iterator begin() const { return const_iterator(_Base::begin(), this); } iterator end() { return iterator(_Base::end(), this); } const_iterator end() const { return const_iterator(_Base::end(), this); } reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } // 21.3.3 capacity: using _Base::size; using _Base::length; using _Base::max_size; void resize(size_type __n, _CharT __c) { _Base::resize(__n, __c); this->_M_invalidate_all(); } void resize(size_type __n) { this->resize(__n, _CharT()); } using _Base::capacity; using _Base::reserve; void clear() { _Base::clear(); this->_M_invalidate_all(); } using _Base::empty; // 21.3.4 element access: const_reference operator[](size_type __pos) const { _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(), _M_message(__gnu_debug::__msg_subscript_oob) ._M_sequence(*this, "this") ._M_integer(__pos, "__pos") ._M_integer(this->size(), "size")); return _M_base()[__pos]; } reference operator[](size_type __pos) { #ifdef _GLIBCXX_DEBUG_PEDANTIC __glibcxx_check_subscript(__pos); #else // as an extension v3 allows s[s.size()] when s is non-const. _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(), _M_message(__gnu_debug::__msg_subscript_oob) ._M_sequence(*this, "this") ._M_integer(__pos, "__pos") ._M_integer(this->size(), "size")); #endif return _M_base()[__pos]; } using _