📄 complex
字号:
__real__ _M_value -= __f; return *this; } inline complex<float>& complex<float>::operator*=(float __f) { _M_value *= __f; return *this; } inline complex<float>& complex<float>::operator/=(float __f) { _M_value /= __f; return *this; } template<typename _Tp> inline complex<float>& complex<float>::operator=(const complex<_Tp>& __z) { __real__ _M_value = __z.real(); __imag__ _M_value = __z.imag(); return *this; } template<typename _Tp> inline complex<float>& complex<float>::operator+=(const complex<_Tp>& __z) { __real__ _M_value += __z.real(); __imag__ _M_value += __z.imag(); return *this; } template<typename _Tp> inline complex<float>& complex<float>::operator-=(const complex<_Tp>& __z) { __real__ _M_value -= __z.real(); __imag__ _M_value -= __z.imag(); return *this; } template<typename _Tp> inline complex<float>& complex<float>::operator*=(const complex<_Tp>& __z) { _ComplexT __t; __real__ __t = __z.real(); __imag__ __t = __z.imag(); _M_value *= __t; return *this; } template<typename _Tp> inline complex<float>& complex<float>::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<double> specialization template<> class complex<double> { public: typedef double value_type; complex(double = 0.0, double = 0.0); complex(const complex<float>&); explicit complex(const complex<long double>&); double& real(); const double& real() const; double& imag(); const double& imag() const; complex<double>& operator=(double); complex<double>& operator+=(double); complex<double>& operator-=(double); complex<double>& operator*=(double); complex<double>& operator/=(double); // The compiler will synthetize this, efficiently. // complex& operator= (const complex&); template<typename _Tp> complex<double>& operator=(const complex<_Tp>&); template<typename _Tp> complex<double>& operator+=(const complex<_Tp>&); template<typename _Tp> complex<double>& operator-=(const complex<_Tp>&); template<typename _Tp> complex<double>& operator*=(const complex<_Tp>&); template<typename _Tp> complex<double>& operator/=(const complex<_Tp>&); private: typedef __complex__ double _ComplexT; _ComplexT _M_value; complex(_ComplexT __z) : _M_value(__z) { } friend class complex<float>; friend class complex<long double>; }; inline double& complex<double>::real() { return __real__ _M_value; } inline const double& complex<double>::real() const { return __real__ _M_value; } inline double& complex<double>::imag() { return __imag__ _M_value; } inline const double& complex<double>::imag() const { return __imag__ _M_value; } inline complex<double>::complex(double __r, double __i) { __real__ _M_value = __r; __imag__ _M_value = __i; } inline complex<double>& complex<double>::operator=(double __d) { __real__ _M_value = __d; __imag__ _M_value = 0.0; return *this; } inline complex<double>& complex<double>::operator+=(double __d) { __real__ _M_value += __d; return *this; } inline complex<double>& complex<double>::operator-=(double __d) { __real__ _M_value -= __d; return *this; } inline complex<double>& complex<double>::operator*=(double __d) { _M_value *= __d; return *this; } inline complex<double>& complex<double>::operator/=(double __d) { _M_value /= __d; return *this; } template<typename _Tp> inline complex<double>& complex<double>::operator=(const complex<_Tp>& __z) { __real__ _M_value = __z.real(); __imag__ _M_value = __z.imag(); return *this; } template<typename _Tp> inline complex<double>& complex<double>::operator+=(const complex<_Tp>& __z) { __real__ _M_value += __z.real(); __imag__ _M_value += __z.imag(); return *this; } template<typename _Tp> inline complex<double>& complex<double>::operator-=(const complex<_Tp>& __z) { __real__ _M_value -= __z.real(); __imag__ _M_value -= __z.imag(); return *this; } template<typename _Tp> inline complex<double>& complex<double>::operator*=(const complex<_Tp>& __z) { _ComplexT __t; __real__ __t = __z.real(); __imag__ __t = __z.imag(); _M_value *= __t; return *this; } template<typename _Tp> inline complex<double>& complex<double>::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<long double> specialization template<> class complex<long double> { public: typedef long double value_type; complex(long double = 0.0L, long double = 0.0L); complex(const complex<float>&); complex(const complex<double>&); long double& real(); const long double& real() const; long double& imag(); const long double& imag() const; complex<long double>& operator= (long double); complex<long double>& operator+= (long double); complex<long double>& operator-= (long double); complex<long double>& operator*= (long double); complex<long double>& operator/= (long double); // The compiler knows how to do this efficiently // complex& operator= (const complex&); template<typename _Tp> complex<long double>& operator=(const complex<_Tp>&); template<typename _Tp> complex<long double>& operator+=(const complex<_Tp>&); template<typename _Tp> complex<long double>& operator-=(const complex<_Tp>&); template<typename _Tp> complex<long double>& operator*=(const complex<_Tp>&); template<typename _Tp> complex<long double>& operator/=(const complex<_Tp>&); private: typedef __complex__ long double _ComplexT; _ComplexT _M_value; complex(_ComplexT __z) : _M_value(__z) { } friend class complex<float>; friend class complex<double>; }; inline complex<long double>::complex(long double __r, long double __i) { __real__ _M_value = __r; __imag__ _M_value = __i; } inline long double& complex<long double>::real() { return __real__ _M_value; } inline const long double& complex<long double>::real() const { return __real__ _M_value; } inline long double& complex<long double>::imag() { return __imag__ _M_value; } inline const long double& complex<long double>::imag() const { return __imag__ _M_value; } inline complex<long double>& complex<long double>::operator=(long double __r) { __real__ _M_value = __r; __imag__ _M_value = 0.0L; return *this; } inline complex<long double>& complex<long double>::operator+=(long double __r) { __real__ _M_value += __r; return *this; } inline complex<long double>& complex<long double>::operator-=(long double __r) { __real__ _M_value -= __r; return *this; } inline complex<long double>& complex<long double>::operator*=(long double __r) { _M_value *= __r; return *this; } inline complex<long double>& complex<long double>::operator/=(long double __r) { _M_value /= __r; return *this; } template<typename _Tp> inline complex<long double>& complex<long double>::operator=(const complex<_Tp>& __z) { __real__ _M_value = __z.real(); __imag__ _M_value = __z.imag(); return *this; } template<typename _Tp> inline complex<long double>& complex<long double>::operator+=(const complex<_Tp>& __z) { __real__ _M_value += __z.real(); __imag__ _M_value += __z.imag(); return *this; } template<typename _Tp> inline complex<long double>& complex<long double>::operator-=(const complex<_Tp>& __z) { __real__ _M_value -= __z.real(); __imag__ _M_value -= __z.imag(); return *this; } template<typename _Tp> inline complex<long double>& complex<long double>::operator*=(const complex<_Tp>& __z) { _ComplexT __t; __real__ __t = __z.real(); __imag__ __t = __z.imag(); _M_value *= __t; return *this; } template<typename _Tp> inline complex<long double>& complex<long double>::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<float>::complex(const complex<double>& __z) : _M_value(_ComplexT(__z._M_value)) { } inline complex<float>::complex(const complex<long double>& __z) : _M_value(_ComplexT(__z._M_value)) { } inline complex<double>::complex(const complex<float>& __z) : _M_value(_ComplexT(__z._M_value)) { } inline complex<double>::complex(const complex<long double>& __z) { __real__ _M_value = __z.real(); __imag__ _M_value = __z.imag(); } inline complex<long double>::complex(const complex<float>& __z) : _M_value(_ComplexT(__z._M_value)) { } inline complex<long double>::complex(const complex<double>& __z) : _M_value(_ComplexT(__z._M_value)) { }} // namespace std#endif /* _GLIBCXX_COMPLEX */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -