std::complex::operator=(3)
π
std::complex::operator=(3) π
okay so bestie, welcome to the std::complex::operator= page from the C++ Standard Libary manual π this is the assignment-operator corner of std::complex, and it's giving βnew value, new meβ energy. no cap, the whole page is about stuffing fresh values into your complex number β¨
πΈ NAME πΈ
std::complex::operator= β literally std::complex::operator= π
β¨ Synopsis β¨
All specializations
complex& operator=( const complex& cx );β until C++20constexpr complex& operator=( const complex& cx );β since C++20template< class X > complex& operator=( const std::complex<X>& cx );β until C++20template< class X > constexpr complex& operator=( const std::complex<X>& cx );β since C++20
Primary template complex<T>
complex& operator=( const T& x );β (1), until C++20constexpr complex& operator=( const T& x );β (2), since C++20
Specializations for standard floating-point types complex<F> (until C++23)
complex& operator=( F x );β (3), until C++20constexpr complex& operator=( F x );β (3), since C++20
okay so what's the actual assignment tea? Assigns new values to the contents. that's the vibe π«Ά
- 1,2) Assigns
cx.real()andcx.imag()to the real and the imaginary parts of the complex number respectively. The copy assignment operator (1) is trivial whenTis a floating-point type. (since C++23) - 3) Assigns
xto the real part of the complex number. Imaginary part is set to zero.
π Parameters π
xβ value to assigncxβ complex value to assign
π Return value π
*this β that's the return, bestie. It hands you back *this π
π Notes π
The copy assignment operator is required to be trivial since C++23, but implementations generally make it trivial in all modes.
π©Ή Defect reports π©Ή
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR
LWG 3935β Applied to:C++98β Behavior as published: the description of overload (2) was missing β Correct behavior: added
π See also π
constructorβ constructs a complex number (public member function)operator""if,operator""i,operator""ilβ astd::complexliteral representing purely imaginary number (function) (C++14)
that's the whole page, bestie π«Ά source/version/date check: http://cppreference.com, 2024.06.10, and this is std::complex::operator=(3) β periodt π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms