std::complex::imag(3)
okay so bestie π welcome to std::complex::imag(3), the manual page from the C++ Standard Libary (yes, that spelling, leave it alone π
). This is all about std::complex::imag: accessing the imaginary part of a complex number. Letβs get into it, no cap β¨
πΈ NAME πΈ
std::complex::imag β std::complex::imag (iconic, self-titled, periodt π)
π¦ Synopsis π¦
ok so hereβs the overload fam. The getter is overload (1) and the setter is overload (2) β thatβs how the page numbers them. The short vibe: imag() with no args gets the imaginary part, and imag(value) sets it π«Ά
primary template
primary template
std::complex<T>
T imag() const; (until C++14)
constexpr T imag() const; (since C++14)
void imag( T value ); (until C++20)
constexpr void imag( T value ); (since C++20)
specialization std::complex<float>
specialization
std::complex<float>
float imag() const; (until C++11)
constexpr float imag() const; (since C++11)
void imag( float value ); (until C++20)
constexpr void imag( float value ); (since C++20)
specialization std::complex<double>
specialization
std::complex<double>
double imag() const; (until C++11)
constexpr double imag() const; (since C++11)
void imag( double value ); (until C++20)
constexpr void imag( double value ); (since C++20)
specialization std::complex<long double>
specialization
std::complex<long double>
long double imag() const; (until C++11)
constexpr long double imag() const; (since C++11)
void imag( long double value ); (until C++20)
constexpr void imag( long double value ); (since C++20)
Accesses the imaginary part of the complex number β¨
- Returns the imaginary part.
- Sets the imaginary part to
value.
π Parameters π
valueβ the value to set the imaginary part to
π Return value π
- The imaginary part of
*this. - (none)
π§ Notes π§
In C++11, overload (1) in std::complex specializations used to be specified without const qualifier. However, in C++11, a constexpr specifier used in a non-static member function implies const, and thus the behavior is as if const is specified.
π Defect reports π
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR
LWG 387- Applied to
C++98 - Behavior as published the imaginary part could not be set directly
- Correct behavior can be set directly via a new
imagoverload
- Applied to
π¦ See also π¦
imagreturns the imaginary part (function template)realaccesses the real part of the complex number (public member function)
okay thatβs the whole vibe, bestie π«Ά this page is from http://cppreference.com, dated 2024.06.10, and its manual tag is std::complex::imag(3). mwah πβ¨
π¦ 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