Files
2025-10-25 03:02:53 +03:00

5.8 KiB
Raw Permalink Blame History

[complex.ops]

29 Numerics library [numerics]

29.4 Complex numbers [complex.numbers]

29.4.6 Non-member operations [complex.ops]

🔗

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

1

#

Returns: complex(lhs).

🔗

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

2

#

Returns: complex(lhs) += rhs.

🔗

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

3

#

Returns: complex(-lhs.real(),-lhs.imag()).

🔗

template<class T> constexpr complex<T> operator-(const complex<T>& lhs, const complex<T>& rhs); template<class T> constexpr complex<T> operator-(const complex<T>& lhs, const T& rhs); template<class T> constexpr complex<T> operator-(const T& lhs, const complex<T>& rhs);

4

#

Returns: complex(lhs) -= rhs.

🔗

template<class T> constexpr complex<T> operator*(const complex<T>& lhs, const complex<T>& rhs); template<class T> constexpr complex<T> operator*(const complex<T>& lhs, const T& rhs); template<class T> constexpr complex<T> operator*(const T& lhs, const complex<T>& rhs);

5

#

Returns: complex(lhs) *= rhs.

🔗

template<class T> constexpr complex<T> operator/(const complex<T>& lhs, const complex<T>& rhs); template<class T> constexpr complex<T> operator/(const complex<T>& lhs, const T& rhs); template<class T> constexpr complex<T> operator/(const T& lhs, const complex<T>& rhs);

6

#

Returns: complex(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);

7

#

Returns: lhs.real() == rhs.real() && lhs.imag() == rhs.imag().

8

#

Remarks: The imaginary part is assumed to beT(), or 0.0, for theT arguments.

🔗

template<class T, class charT, class traits> basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& is, complex<T>& x);

9

#

Preconditions: The input values are convertible toT.

10

#

Effects: Extracts a complex number x of the form:u,(u), or(u,v), whereu is the real part andv is the imaginary part ([istream.formatted]).

11

#

If bad input is encountered, callsis.setstate(ios_base::failbit) (which may throwios_base::failure ([iostate.flags])).

12

#

Returns: is.

13

#

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);

14

#

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

15

#

[Note 1:

In a locale in which comma is used as a decimal point character, the use of comma as a field separator can be ambiguous.

Insertingshowpoint 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]