Commit c14286b0 by Benjamin Kosnik

[multiple changes]


2000-07-03  Benjamin Kosnik  <bkoz@purist.soma.redhat.com>

	* bits/std_memory.h: Revert.

2000-07-03  Brendan Kehoe  <brendan@zen.org>

	* bits/std_complex.h: Fix parens. Format.

From-SVN: r34857
parent 18fa319d
2000-07-03 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
* bits/std_memory.h: Revert.
2000-07-03 Brendan Kehoe <brendan@zen.org>
* bits/std_complex.h: Fix parens. Format.
2000-07-01 Benjamin Kosnik <bkoz@purist.soma.redhat.com> 2000-07-01 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
Ulrich Drepper <drepper@purist.soma.redhat.com> Ulrich Drepper <drepper@purist.soma.redhat.com>
......
// The template and inlines for the -*- C++ -*- complex number classes. // The template and inlines for the -*- C++ -*- complex number classes.
// Copyright (C) 1997-1999 Free Software Foundation, Inc. // Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
#include <bits/c++config.h> #include <bits/c++config.h>
#include <bits/std_iosfwd.h> #include <bits/std_iosfwd.h>
namespace std namespace std
{ {
// Forward declarations // Forward declarations
template<typename _Tp> class complex; template<typename _Tp> class complex;
template<> class complex<float>; template<> class complex<float>;
...@@ -82,37 +82,35 @@ namespace std ...@@ -82,37 +82,35 @@ namespace std
public: public:
typedef _Tp value_type; typedef _Tp value_type;
complex (const _Tp& = _Tp(), const _Tp & = _Tp()); complex(const _Tp& = _Tp(), const _Tp & = _Tp());
// Let's the compiler synthetize the copy constructor // Let's the compiler synthetize the copy constructor
// complex (const complex<_Tp>&); // complex (const complex<_Tp>&);
template <typename _Up> template <typename _Up>
complex (const complex<_Up>&); complex(const complex<_Up>&);
_Tp real () const; _Tp real() const;
_Tp imag () const; _Tp imag() const;
complex<_Tp>& operator= (const _Tp&); complex<_Tp>& operator=(const _Tp&);
complex<_Tp>& operator+= (const _Tp&); complex<_Tp>& operator+=(const _Tp&);
complex<_Tp>& operator-= (const _Tp&); complex<_Tp>& operator-=(const _Tp&);
complex<_Tp>& operator*= (const _Tp&); complex<_Tp>& operator*=(const _Tp&);
complex<_Tp>& operator/= (const _Tp&); complex<_Tp>& operator/=(const _Tp&);
// Let's the compiler synthetize the // Let's the compiler synthetize the
// copy and assignment operator // copy and assignment operator
// complex<_Tp>& operator= (const complex<_Tp>&); // complex<_Tp>& operator= (const complex<_Tp>&);
template <typename _Up> template <typename _Up>
complex<_Tp>& operator= (const complex<_Up>&); complex<_Tp>& operator=(const complex<_Up>&);
template <typename _Up> template <typename _Up>
complex<_Tp>& operator+= (const complex<_Up>&); complex<_Tp>& operator+=(const complex<_Up>&);
template <typename _Up> template <typename _Up>
complex<_Tp>& operator-= (const complex<_Up>&); complex<_Tp>& operator-=(const complex<_Up>&);
template <typename _Up> template <typename _Up>
complex<_Tp>& operator*= (const complex<_Up>&); complex<_Tp>& operator*=(const complex<_Up>&);
template <typename _Up> template <typename _Up>
complex<_Tp>& operator/= (const complex<_Up>&); complex<_Tp>& operator/=(const complex<_Up>&);
private: private:
_Tp _M_real, _M_imag; _Tp _M_real, _M_imag;
...@@ -141,7 +139,7 @@ namespace std ...@@ -141,7 +139,7 @@ namespace std
complex(float = 0.0f, float = 0.0f); complex(float = 0.0f, float = 0.0f);
#ifdef _GLIBCPP_BUGGY_COMPLEX #ifdef _GLIBCPP_BUGGY_COMPLEX
complex(const complex& __z) : _M_value(__z._M_value) {} complex(const complex& __z) : _M_value(__z._M_value) { }
#endif #endif
explicit complex(const complex<double>&); explicit complex(const complex<double>&);
explicit complex(const complex<long double>&); explicit complex(const complex<long double>&);
...@@ -149,32 +147,31 @@ namespace std ...@@ -149,32 +147,31 @@ namespace std
float real() const; float real() const;
float imag() const; float imag() const;
complex<float>& operator= (float); complex<float>& operator=(float);
complex<float>& operator+= (float); complex<float>& operator+=(float);
complex<float>& operator-= (float); complex<float>& operator-=(float);
complex<float>& operator*= (float); complex<float>& operator*=(float);
complex<float>& operator/= (float); complex<float>& operator/=(float);
// Let's the compiler synthetize the copy and assignment // Let's the compiler synthetize the copy and assignment
// operator. It always does a pretty good job. // operator. It always does a pretty good job.
// complex& operator= (const complex&); // complex& operator= (const complex&);
template <typename _Tp> template <typename _Tp>
complex<float>&operator= (const complex<_Tp>&); complex<float>&operator=(const complex<_Tp>&);
template <typename _Tp> template <typename _Tp>
complex<float>& operator+= (const complex<_Tp>&); complex<float>& operator+=(const complex<_Tp>&);
template <class _Tp> template <class _Tp>
complex<float>& operator-= (const complex<_Tp>&); complex<float>& operator-=(const complex<_Tp>&);
template <class _Tp> template <class _Tp>
complex<float>& operator*= (const complex<_Tp>&); complex<float>& operator*=(const complex<_Tp>&);
template <class _Tp> template <class _Tp>
complex<float>&operator/= (const complex<_Tp>&); complex<float>&operator/=(const complex<_Tp>&);
private: private:
typedef __complex__ float _ComplexT; typedef __complex__ float _ComplexT;
_ComplexT _M_value; _ComplexT _M_value;
complex(_ComplexT __z) : _M_value(__z) {} complex(_ComplexT __z) : _M_value(__z) { }
friend class complex<double>; friend class complex<double>;
friend class complex<long double>; friend class complex<long double>;
...@@ -220,39 +217,38 @@ namespace std ...@@ -220,39 +217,38 @@ namespace std
complex(double =0.0, double =0.0); complex(double =0.0, double =0.0);
#ifdef _GLIBCPP_BUGGY_COMPLEX #ifdef _GLIBCPP_BUGGY_COMPLEX
complex(const complex& __z) : _M_value(__z._M_value) {} complex(const complex& __z) : _M_value(__z._M_value) { }
#endif #endif
complex(const complex<float>&); complex(const complex<float>&);
explicit complex(const complex<long double>&); 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); 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. // The compiler will synthetize this, efficiently.
// complex& operator= (const complex&); // complex& operator= (const complex&);
template <typename _Tp> template <typename _Tp>
complex<double>& operator= (const complex<_Tp>&); complex<double>& operator=(const complex<_Tp>&);
template <typename _Tp> template <typename _Tp>
complex<double>& operator+= (const complex<_Tp>&); complex<double>& operator+=(const complex<_Tp>&);
template <typename _Tp> template <typename _Tp>
complex<double>& operator-= (const complex<_Tp>&); complex<double>& operator-=(const complex<_Tp>&);
template <typename _Tp> template <typename _Tp>
complex<double>& operator*= (const complex<_Tp>&); complex<double>& operator*=(const complex<_Tp>&);
template <typename _Tp> template <typename _Tp>
complex<double>& operator/= (const complex<_Tp>&); complex<double>& operator/=(const complex<_Tp>&);
private: private:
typedef __complex__ double _ComplexT; typedef __complex__ double _ComplexT;
_ComplexT _M_value; _ComplexT _M_value;
complex(_ComplexT __z) : _M_value(__z) {} complex(_ComplexT __z) : _M_value(__z) { }
friend class complex<float>; friend class complex<float>;
friend class complex<long double>; friend class complex<long double>;
...@@ -261,7 +257,6 @@ namespace std ...@@ -261,7 +257,6 @@ namespace std
friend double arg<>(const complex<double>&); friend double arg<>(const complex<double>&);
friend complex<double> conj<>(const complex<double>&); friend complex<double> conj<>(const complex<double>&);
friend complex<double> cos<>(const complex<double>&); friend complex<double> cos<>(const complex<double>&);
friend complex<double> cosh<>(const complex<double>&); friend complex<double> cosh<>(const complex<double>&);
friend complex<double> exp<>(const complex<double>&); friend complex<double> exp<>(const complex<double>&);
...@@ -298,7 +293,7 @@ namespace std ...@@ -298,7 +293,7 @@ namespace std
complex(long double = 0.0L, long double = 0.0L); complex(long double = 0.0L, long double = 0.0L);
#ifdef _GLIBCPP_BUGGY_COMPLEX #ifdef _GLIBCPP_BUGGY_COMPLEX
complex(const complex& __z) : _M_value(__z._M_value) {} complex(const complex& __z) : _M_value(__z._M_value) { }
#endif #endif
complex(const complex<float>&); complex(const complex<float>&);
complex(const complex<double>&); complex(const complex<double>&);
...@@ -316,21 +311,21 @@ namespace std ...@@ -316,21 +311,21 @@ namespace std
// complex& operator= (const complex&); // complex& operator= (const complex&);
template<typename _Tp> template<typename _Tp>
complex<long double>& operator= (const complex<_Tp>&); complex<long double>& operator=(const complex<_Tp>&);
template<typename _Tp> template<typename _Tp>
complex<long double>& operator+= (const complex<_Tp>&); complex<long double>& operator+=(const complex<_Tp>&);
template<typename _Tp> template<typename _Tp>
complex<long double>& operator-= (const complex<_Tp>&); complex<long double>& operator-=(const complex<_Tp>&);
template<typename _Tp> template<typename _Tp>
complex<long double>& operator*= (const complex<_Tp>&); complex<long double>& operator*=(const complex<_Tp>&);
template<typename _Tp> template<typename _Tp>
complex<long double>& operator/= (const complex<_Tp>&); complex<long double>& operator/=(const complex<_Tp>&);
private: private:
typedef __complex__ long double _ComplexT; typedef __complex__ long double _ComplexT;
_ComplexT _M_value; _ComplexT _M_value;
complex(_ComplexT __z) : _M_value(__z) {} complex(_ComplexT __z) : _M_value(__z) { }
friend class complex<float>; friend class complex<float>;
friend class complex<double>; friend class complex<double>;
...@@ -339,7 +334,6 @@ namespace std ...@@ -339,7 +334,6 @@ namespace std
friend long double arg<>(const complex<long double>&); friend long double arg<>(const complex<long double>&);
friend complex<long double> conj<>(const complex<long double>&); friend complex<long double> conj<>(const complex<long double>&);
friend complex<long double> cos<>(const complex<long double>&); friend complex<long double> cos<>(const complex<long double>&);
friend complex<long double> cosh<>(const complex<long double>&); friend complex<long double> cosh<>(const complex<long double>&);
friend complex<long double> exp<>(const complex<long double>&); friend complex<long double> exp<>(const complex<long double>&);
...@@ -368,11 +362,11 @@ namespace std ...@@ -368,11 +362,11 @@ namespace std
inline inline
complex<long double>::complex(const complex<float>& __z) complex<long double>::complex(const complex<float>& __z)
: _M_value(_ComplexT(__z._M_value)) {} : _M_value(_ComplexT(__z._M_value)) { }
inline inline
complex<long double>::complex(const complex<double>& __z) complex<long double>::complex(const complex<double>& __z)
: _M_value(_ComplexT(__z._M_value)) {} : _M_value(_ComplexT(__z._M_value)) { }
inline long double inline long double
complex<long double>::real() const complex<long double>::real() const
...@@ -383,7 +377,7 @@ namespace std ...@@ -383,7 +377,7 @@ namespace std
{ return __imag__ _M_value; } { return __imag__ _M_value; }
inline complex<long double>& inline complex<long double>&
complex<long double>::operator= (long double __r) complex<long double>::operator=(long double __r)
{ {
__real__ _M_value = __r; __real__ _M_value = __r;
__imag__ _M_value = 0.0L; __imag__ _M_value = 0.0L;
...@@ -391,28 +385,28 @@ namespace std ...@@ -391,28 +385,28 @@ namespace std
} }
inline complex<long double>& inline complex<long double>&
complex<long double>::operator+= (long double __r) complex<long double>::operator+=(long double __r)
{ {
__real__ _M_value += __r; __real__ _M_value += __r;
return *this; return *this;
} }
inline complex<long double>& inline complex<long double>&
complex<long double>::operator-= (long double __r) complex<long double>::operator-=(long double __r)
{ {
__real__ _M_value -= __r; __real__ _M_value -= __r;
return *this; return *this;
} }
inline complex<long double>& inline complex<long double>&
complex<long double>::operator*= (long double __r) complex<long double>::operator*=(long double __r)
{ {
__real__ _M_value *= __r; __real__ _M_value *= __r;
return *this; return *this;
} }
inline complex<long double>& inline complex<long double>&
complex<long double>::operator/= (long double __r) complex<long double>::operator/=(long double __r)
{ {
__real__ _M_value /= __r; __real__ _M_value /= __r;
return *this; return *this;
...@@ -420,7 +414,7 @@ namespace std ...@@ -420,7 +414,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<long double>& inline complex<long double>&
complex<long double>::operator= (const complex<_Tp>& __z) complex<long double>::operator=(const complex<_Tp>& __z)
{ {
__real__ _M_value = __z.real(); __real__ _M_value = __z.real();
__imag__ _M_value = __z.imag(); __imag__ _M_value = __z.imag();
...@@ -429,7 +423,7 @@ namespace std ...@@ -429,7 +423,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<long double>& inline complex<long double>&
complex<long double>::operator+= (const complex<_Tp>& __z) complex<long double>::operator+=(const complex<_Tp>& __z)
{ {
__real__ _M_value += __z.real(); __real__ _M_value += __z.real();
__imag__ _M_value += __z.imag(); __imag__ _M_value += __z.imag();
...@@ -438,7 +432,7 @@ namespace std ...@@ -438,7 +432,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<long double>& inline complex<long double>&
complex<long double>::operator-= (const complex<_Tp>& __z) complex<long double>::operator-=(const complex<_Tp>& __z)
{ {
__real__ _M_value -= __z.real(); __real__ _M_value -= __z.real();
__imag__ _M_value -= __z.imag(); __imag__ _M_value -= __z.imag();
...@@ -447,7 +441,7 @@ namespace std ...@@ -447,7 +441,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<long double>& inline complex<long double>&
complex<long double>::operator*= (const complex<_Tp>& __z) complex<long double>::operator*=(const complex<_Tp>& __z)
{ {
_ComplexT __t; _ComplexT __t;
__real__ __t = __z.real(); __real__ __t = __z.real();
...@@ -458,7 +452,7 @@ namespace std ...@@ -458,7 +452,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<long double>& inline complex<long double>&
complex<long double>::operator/= (const complex<_Tp>& __z) complex<long double>::operator/=(const complex<_Tp>& __z)
{ {
_ComplexT __t; _ComplexT __t;
__real__ __t = __z.real(); __real__ __t = __z.real();
...@@ -479,14 +473,14 @@ namespace std ...@@ -479,14 +473,14 @@ namespace std
inline inline
complex<float>::complex(const complex<double>& __z) complex<float>::complex(const complex<double>& __z)
: _M_value(_ComplexT(__z._M_value)) {} : _M_value(_ComplexT(__z._M_value)) { }
inline inline
complex<float>::complex(const complex<long double>& __z) complex<float>::complex(const complex<long double>& __z)
: _M_value(_ComplexT(__z._M_value)) {} : _M_value(_ComplexT(__z._M_value)) { }
inline complex<float>& inline complex<float>&
complex<float>::operator= (float __f) complex<float>::operator=(float __f)
{ {
__real__ _M_value = __f; __real__ _M_value = __f;
__imag__ _M_value = 0.0f; __imag__ _M_value = 0.0f;
...@@ -494,28 +488,28 @@ namespace std ...@@ -494,28 +488,28 @@ namespace std
} }
inline complex<float>& inline complex<float>&
complex<float>::operator+= (float __f) complex<float>::operator+=(float __f)
{ {
__real__ _M_value += __f; __real__ _M_value += __f;
return *this; return *this;
} }
inline complex<float>& inline complex<float>&
complex<float>::operator-= (float __f) complex<float>::operator-=(float __f)
{ {
__real__ _M_value -= __f; __real__ _M_value -= __f;
return *this; return *this;
} }
inline complex<float>& inline complex<float>&
complex<float>::operator*= (float __f) complex<float>::operator*=(float __f)
{ {
_M_value *= __f; _M_value *= __f;
return *this; return *this;
} }
inline complex<float>& inline complex<float>&
complex<float>::operator/= (float __f) complex<float>::operator/=(float __f)
{ {
_M_value /= __f; _M_value /= __f;
return *this; return *this;
...@@ -523,7 +517,7 @@ namespace std ...@@ -523,7 +517,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<float>& inline complex<float>&
complex<float>::operator= (const complex<_Tp>& __z) complex<float>::operator=(const complex<_Tp>& __z)
{ {
__real__ _M_value = __z.real(); __real__ _M_value = __z.real();
__imag__ _M_value = __z.imag(); __imag__ _M_value = __z.imag();
...@@ -532,7 +526,7 @@ namespace std ...@@ -532,7 +526,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<float>& inline complex<float>&
complex<float>::operator+= (const complex<_Tp>& __z) complex<float>::operator+=(const complex<_Tp>& __z)
{ {
__real__ _M_value += __z.real(); __real__ _M_value += __z.real();
__imag__ _M_value += __z.imag(); __imag__ _M_value += __z.imag();
...@@ -541,7 +535,7 @@ namespace std ...@@ -541,7 +535,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<float>& inline complex<float>&
complex<float>::operator-= (const complex<_Tp>& __z) complex<float>::operator-=(const complex<_Tp>& __z)
{ {
__real__ _M_value -= __z.real(); __real__ _M_value -= __z.real();
__imag__ _M_value -= __z.real(); __imag__ _M_value -= __z.real();
...@@ -550,7 +544,7 @@ namespace std ...@@ -550,7 +544,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<float>& inline complex<float>&
complex<float>::operator*= (const complex<_Tp>& __z) complex<float>::operator*=(const complex<_Tp>& __z)
{ {
_ComplexT __t; _ComplexT __t;
__real__ __t = __z.real(); __real__ __t = __z.real();
...@@ -561,7 +555,7 @@ namespace std ...@@ -561,7 +555,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<float>& inline complex<float>&
complex<float>::operator/= (const complex<_Tp>& __z) complex<float>::operator/=(const complex<_Tp>& __z)
{ {
_ComplexT __t; _ComplexT __t;
__real__ __t = __z.real(); __real__ __t = __z.real();
...@@ -583,7 +577,7 @@ namespace std ...@@ -583,7 +577,7 @@ namespace std
inline inline
complex<double>::complex(const complex<float>& __z) complex<double>::complex(const complex<float>& __z)
: _M_value(_ComplexT(__z._M_value)) {} : _M_value(_ComplexT(__z._M_value)) { }
inline inline
complex<double>::complex(const complex<long double>& __z) complex<double>::complex(const complex<long double>& __z)
...@@ -593,7 +587,7 @@ namespace std ...@@ -593,7 +587,7 @@ namespace std
} }
inline complex<double>& inline complex<double>&
complex<double>::operator= (double __d) complex<double>::operator=(double __d)
{ {
__real__ _M_value = __d; __real__ _M_value = __d;
__imag__ _M_value = 0.0; __imag__ _M_value = 0.0;
...@@ -601,28 +595,28 @@ namespace std ...@@ -601,28 +595,28 @@ namespace std
} }
inline complex<double>& inline complex<double>&
complex<double>::operator+= (double __d) complex<double>::operator+=(double __d)
{ {
__real__ _M_value += __d; __real__ _M_value += __d;
return *this; return *this;
} }
inline complex<double>& inline complex<double>&
complex<double>::operator-= (double __d) complex<double>::operator-=(double __d)
{ {
__real__ _M_value -= __d; __real__ _M_value -= __d;
return *this; return *this;
} }
inline complex<double>& inline complex<double>&
complex<double>::operator*= (double __d) complex<double>::operator*=(double __d)
{ {
_M_value *= __d; _M_value *= __d;
return *this; return *this;
} }
inline complex<double>& inline complex<double>&
complex<double>::operator/= (double __d) complex<double>::operator/=(double __d)
{ {
_M_value /= __d; _M_value /= __d;
return *this; return *this;
...@@ -630,7 +624,7 @@ namespace std ...@@ -630,7 +624,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<double>& inline complex<double>&
complex<double>::operator= (const complex<_Tp>& __z) complex<double>::operator=(const complex<_Tp>& __z)
{ {
__real__ _M_value = __z.real(); __real__ _M_value = __z.real();
__imag__ _M_value = __z.imag(); __imag__ _M_value = __z.imag();
...@@ -639,7 +633,7 @@ namespace std ...@@ -639,7 +633,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<double>& inline complex<double>&
complex<double>::operator+= (const complex<_Tp>& __z) complex<double>::operator+=(const complex<_Tp>& __z)
{ {
__real__ _M_value += __z.real(); __real__ _M_value += __z.real();
__imag__ _M_value += __z.imag(); __imag__ _M_value += __z.imag();
...@@ -648,7 +642,7 @@ namespace std ...@@ -648,7 +642,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<double>& inline complex<double>&
complex<double>::operator-= (const complex<_Tp>& __z) complex<double>::operator-=(const complex<_Tp>& __z)
{ {
__real__ _M_value -= __z.real(); __real__ _M_value -= __z.real();
__imag__ _M_value -= __z.imag(); __imag__ _M_value -= __z.imag();
...@@ -657,7 +651,7 @@ namespace std ...@@ -657,7 +651,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<double>& inline complex<double>&
complex<double>::operator*= (const complex<_Tp>& __z) complex<double>::operator*=(const complex<_Tp>& __z)
{ {
_ComplexT __t; _ComplexT __t;
__real__ __t = __z.real(); __real__ __t = __z.real();
...@@ -668,7 +662,7 @@ namespace std ...@@ -668,7 +662,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline complex<double>& inline complex<double>&
complex<double>::operator/= (const complex<_Tp>& __z) complex<double>::operator/=(const complex<_Tp>& __z)
{ {
_ComplexT __t; _ComplexT __t;
__real__ __t = __z.real(); __real__ __t = __z.real();
...@@ -684,13 +678,13 @@ namespace std ...@@ -684,13 +678,13 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline inline
complex<_Tp>::complex(const _Tp& __r, const _Tp& __i) complex<_Tp>::complex(const _Tp& __r, const _Tp& __i)
: _M_real(__r), _M_imag(__i) {} : _M_real(__r), _M_imag(__i) { }
template<typename _Tp> template<typename _Tp>
template<typename _Up> template<typename _Up>
inline inline
complex<_Tp>::complex(const complex<_Up>& __z) complex<_Tp>::complex(const complex<_Up>& __z)
: _M_real(__z.real()), _M_imag(__z.imag()) {} : _M_real(__z.real()), _M_imag(__z.imag()) { }
// 26.2.7/6 // 26.2.7/6
template<typename _Tp> template<typename _Tp>
...@@ -709,7 +703,7 @@ namespace std ...@@ -709,7 +703,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
complex<_Tp>& complex<_Tp>&
complex<_Tp>::operator= (const _Tp& __t) complex<_Tp>::operator=(const _Tp& __t)
{ {
_M_real = __t; _M_real = __t;
_M_imag = _Tp(); _M_imag = _Tp();
...@@ -719,7 +713,7 @@ namespace std ...@@ -719,7 +713,7 @@ namespace std
// 26.2.5/1 // 26.2.5/1
template<typename _Tp> template<typename _Tp>
inline complex<_Tp>& inline complex<_Tp>&
complex<_Tp>::operator+= (const _Tp& __t) complex<_Tp>::operator+=(const _Tp& __t)
{ {
_M_real += __t; _M_real += __t;
return *this; return *this;
...@@ -728,7 +722,7 @@ namespace std ...@@ -728,7 +722,7 @@ namespace std
// 26.2.5/3 // 26.2.5/3
template<typename _Tp> template<typename _Tp>
inline complex<_Tp>& inline complex<_Tp>&
complex<_Tp>::operator-= (const _Tp& __t) complex<_Tp>::operator-=(const _Tp& __t)
{ {
_M_real -= __t; _M_real -= __t;
return *this; return *this;
...@@ -737,7 +731,7 @@ namespace std ...@@ -737,7 +731,7 @@ namespace std
// 26.2.5/5 // 26.2.5/5
template<typename _Tp> template<typename _Tp>
complex<_Tp>& complex<_Tp>&
complex<_Tp>::operator*= (const _Tp& __t) complex<_Tp>::operator*=(const _Tp& __t)
{ {
_M_real *= __t; _M_real *= __t;
_M_imag *= __t; _M_imag *= __t;
...@@ -747,7 +741,7 @@ namespace std ...@@ -747,7 +741,7 @@ namespace std
// 26.2.5/7 // 26.2.5/7
template<typename _Tp> template<typename _Tp>
complex<_Tp>& complex<_Tp>&
complex<_Tp>::operator/= (const _Tp& __t) complex<_Tp>::operator/=(const _Tp& __t)
{ {
_M_real /= __t; _M_real /= __t;
_M_imag /= __t; _M_imag /= __t;
...@@ -757,7 +751,7 @@ namespace std ...@@ -757,7 +751,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
template<typename _Up> template<typename _Up>
complex<_Tp>& complex<_Tp>&
complex<_Tp>::operator= (const complex<_Up>& __z) complex<_Tp>::operator=(const complex<_Up>& __z)
{ {
_M_real = __z.real(); _M_real = __z.real();
_M_imag = __z.imag(); _M_imag = __z.imag();
...@@ -768,7 +762,7 @@ namespace std ...@@ -768,7 +762,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
template<typename _Up> template<typename _Up>
complex<_Tp>& complex<_Tp>&
complex<_Tp>::operator+= (const complex<_Up>& __z) complex<_Tp>::operator+=(const complex<_Up>& __z)
{ {
_M_real += __z.real(); _M_real += __z.real();
_M_imag += __z.imag(); _M_imag += __z.imag();
...@@ -779,7 +773,7 @@ namespace std ...@@ -779,7 +773,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
template<typename _Up> template<typename _Up>
complex<_Tp>& complex<_Tp>&
complex<_Tp>::operator-= (const complex<_Up>& __z) complex<_Tp>::operator-=(const complex<_Up>& __z)
{ {
_M_real -= __z.real(); _M_real -= __z.real();
_M_imag -= __z.imag(); _M_imag -= __z.imag();
...@@ -791,7 +785,7 @@ namespace std ...@@ -791,7 +785,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
template<typename _Up> template<typename _Up>
complex<_Tp>& complex<_Tp>&
complex<_Tp>::operator*= (const complex<_Up>& __z) complex<_Tp>::operator*=(const complex<_Up>& __z)
{ {
_Tp __r = _M_real * __z.real() - _M_imag * __z.imag(); _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();
_M_imag = _M_real * __z.imag() + _M_imag * __z.real(); _M_imag = _M_real * __z.imag() + _M_imag * __z.real();
...@@ -804,7 +798,7 @@ namespace std ...@@ -804,7 +798,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
template<typename _Up> template<typename _Up>
complex<_Tp>& complex<_Tp>&
complex<_Tp>::operator/= (const complex<_Up>& __z) complex<_Tp>::operator/=(const complex<_Up>& __z)
{ {
_Tp __r = _M_real * __z.real() + _M_imag * __z.imag(); _Tp __r = _M_real * __z.real() + _M_imag * __z.imag();
_Tp __n = norm(__z); _Tp __n = norm(__z);
...@@ -813,7 +807,6 @@ namespace std ...@@ -813,7 +807,6 @@ namespace std
return *this; return *this;
} }
// Operators: // Operators:
template<typename _Tp> template<typename _Tp>
inline complex<_Tp> inline complex<_Tp>
...@@ -888,7 +881,7 @@ namespace std ...@@ -888,7 +881,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline bool inline bool
operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
{ return __x.real() == __y.real() && __x.imag == __y.imag(); } { return __x.real() == __y.real() && __x.imag() == __y.imag(); }
template<typename _Tp> template<typename _Tp>
inline bool inline bool
...@@ -927,12 +920,12 @@ namespace std ...@@ -927,12 +920,12 @@ namespace std
// Values: // Values:
template <typename _Tp> template <typename _Tp>
inline _Tp inline _Tp
real (const complex<_Tp>& __z) real(const complex<_Tp>& __z)
{ return __z.real(); } { return __z.real(); }
template <typename _Tp> template <typename _Tp>
inline _Tp inline _Tp
imag (const complex<_Tp>& __z) imag(const complex<_Tp>& __z)
{ return __z.imag(); } { return __z.imag(); }
...@@ -957,10 +950,12 @@ namespace std ...@@ -957,10 +950,12 @@ namespace std
template<> template<>
inline complex<long double> inline complex<long double>
conj(const complex<long double> &__x) conj(const complex<long double> &__x)
{ { return complex<long double> (~__x._M_value); }
return complex<long double> (~__x._M_value);
}
} // namespace std } // namespace std
#endif /* _CPP_COMPLEX */ #endif /* _CPP_COMPLEX */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment