std::complex<T>::imag
| primary template std::complex<T> |
||
| (1) | ||
T imag() const; |
(until C++14) | |
| constexpr T imag() const; |
(since C++14) | |
| (2) | ||
void imag( T value ); |
(until C++20) | |
| constexpr void imag( T value ); |
(since C++20) | |
| specialization std::complex<float> |
||
| (1) | ||
float imag() const; |
(until C++11) | |
| constexpr float imag() const; |
(since C++11) | |
| (2) | ||
void imag( float value ); |
(until C++20) | |
| constexpr void imag( float value ); |
(since C++20) | |
| specialization std::complex<double> |
||
| (1) | ||
double imag() const; |
(until C++11) | |
| constexpr double imag() const; |
(since C++11) | |
| (2) | ||
void imag( double value ); |
(until C++20) | |
| constexpr void imag( double value ); |
(since C++20) | |
| specialization std::complex<long double> |
||
| (1) | ||
long double imag() const; |
(until C++11) | |
| constexpr long double imag() const; |
(since C++11) | |
| (2) | ||
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.
Contents |
[edit] Parameters
| value | - | the value to set the imaginary part to |
[edit] Return value
[edit] 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.
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 387 | C++98 | the imaginary part could not be set directly | can be set directly via a new imag overload
|
[edit] See also
| returns the imaginary part (function template) | |
| accesses the real part of the complex number (public member function) |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
