template<class T> complex<T> operator+(const complex<T>& lhs);
Returns:
complex<T>(lhs). template<class T> complex<T> operator+(const complex<T>& lhs, const complex<T>& rhs);
template<class T> complex<T> operator+(const complex<T>& lhs, const T& rhs);
template<class T> complex<T> operator+(const T& lhs, const complex<T>& rhs);
Returns:
complex<T>(lhs) += rhs. template<class T> complex<T> operator-(const complex<T>& lhs);
Returns:
complex<T>(-lhs.real(),-lhs.imag()). template<class T> complex<T> operator-(const complex<T>& lhs, const complex<T>& rhs);
template<class T> complex<T> operator-(const complex<T>& lhs, const T& rhs);
template<class T> complex<T> operator-(const T& lhs, const complex<T>& rhs);
Returns:
complex<T>(lhs) -= rhs. template<class T> complex<T> operator*(const complex<T>& lhs, const complex<T>& rhs);
template<class T> complex<T> operator*(const complex<T>& lhs, const T& rhs);
template<class T> complex<T> operator*(const T& lhs, const complex<T>& rhs);
Returns:
complex<T>(lhs) *= rhs. template<class T> complex<T> operator/(const complex<T>& lhs, const complex<T>& rhs);
template<class T> complex<T> operator/(const complex<T>& lhs, const T& rhs);
template<class T> complex<T> operator/(const T& lhs, const complex<T>& rhs);
Returns:
complex<T>(lhs) /= rhs. template<class T> constexpr bool operator==(const complex<T>& lhs, const complex<T>& rhs);
template<class T> constexpr bool operator==(const complex<T>& lhs, const T& rhs);
template<class T> constexpr bool operator==(const T& lhs, const complex<T>& rhs);
Returns:
lhs.real() == rhs.real() && lhs.imag() == rhs.imag(). Remarks:
The imaginary part is assumed to be
T(),
or 0
. template<class T> constexpr bool operator!=(const complex<T>& lhs, const complex<T>& rhs);
template<class T> constexpr bool operator!=(const complex<T>& lhs, const T& rhs);
template<class T> constexpr bool operator!=(const T& lhs, const complex<T>& rhs);
Returns:
rhs.real() != lhs.real() || rhs.imag() != lhs.imag(). template<class T, class charT, class traits>
basic_istream<charT, traits>&
operator>>(basic_istream<charT, traits>& is, complex<T>& x);
Requires:
The input values shall be convertible to
T. Effects:
Extracts a complex number
x of the form:
u,
(u),
or
(u,v),
where
u
is the real part and
v
is the imaginary part (
[istream.formatted])
. If bad input is encountered, calls
is.setstate(ios_base::failbit)
(which may throw
ios::failure (
[iostate.flags]))
.Remarks:
This extraction is performed as a series of simpler
extractions
. Therefore, the skipping of whitespace is specified to be
the same for each of the simpler extractions
.template<class T, class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);
Effects:
Inserts the complex number x
onto the stream o as if it were implemented as follows:
basic_ostringstream<charT, traits> s;
s.flags(o.flags());
s.imbue(o.getloc());
s.precision(o.precision());
s << '(' << x.real() << "," << x.imag() << ')';
return o << s.str();
[
Note: In a locale in which comma is used as a decimal point character, the
use of comma as a field separator can be ambiguous
. Inserting
showpoint into the output stream forces all outputs to
show an explicit decimal point character; as a result, all inserted sequences of
complex numbers can be extracted unambiguously
. —
end note ]