29 Numerics library [numerics]

29.5 Complex numbers [complex.numbers]

29.5.6 complex non-member operations [complex.ops]

template<class T> complex<T> operator+(const complex<T>& lhs);

Returns: complex<T>(lhs).

Remarks: унарный оператор.

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()).

Remarks: унарный оператор.

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: Предполагается, что мнимая часть аргументов равна T()0,0 T.

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: Входные значения должны быть преобразованы в T.

Effects: Экстракты комплексного числа x в виде: u, (u)или (u,v), где u это действительная часть и v мнимая часть ([istream.formatted]).

Если обнаруживается неправильный ввод, вызывается is.setstate(ios_­base​::​failbit) (который может throw ios​::​failure ([iostate.flags])).

Returns: is.

Remarks: Эта экстракция выполняется как серия более простых экстракций. Таким образом, пропуск пробелов должен быть одинаковым для всех более простых извлечений.

template<class T, class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);

Effects: Вставляет комплексное число x в поток, o как если бы это было реализовано следующим образом:

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: В языковом стандарте, в котором запятая используется в качестве символа десятичной точки, использование запятой в качестве разделителя полей может быть неоднозначным. Вставка showpoint в выходной поток заставляет все выходные данные показывать явный десятичный знак; в результате все вставленные последовательности комплексных чисел могут быть однозначно извлечены. ] end note