table of contents
std::complex::imag(3) | C++ Standard Libary | std::complex::imag(3) |
NAME¶
std::complex::imag - std::complex::imag
Synopsis¶
primary template
std::complex<T>
T imag() const; (until
C++14)
constexpr T imag() (since
const; C++14)
void imag( T value (until
); C++20)
constexpr void imag( (since
T value ); C++20)
specialization
std::complex<float>
float imag() const; (until
C++11)
constexpr float (since
imag() const; C++11)
void imag( float (until
value ); C++20)
constexpr void imag( (since
float value ); C++20)
specialization
std::complex<double> (1)
double imag() const; (until
(2) C++11)
constexpr double (since
imag() const; C++11)
void imag( double (1) (until
value ); C++20)
constexpr void imag( (2) (since
double value ); C++20)
specialization
std::complex<long (1)
double>
long double imag() (2) (until
const; C++11)
constexpr long (since
double imag() const; (1) C++11)
void imag( long (until
double value ); (2) C++20)
constexpr void imag( (since
long double value ); C++20)
Accesses the imaginary part of the complex number.
1) Returns the imaginary part.
2) Sets the imaginary part to value.
Parameters¶
value - the value to set the imaginary part to
Return value¶
1) The imaginary part of *this.
2) (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 Applied to Behavior as published Correct behavior
LWG 387 C++98 the imaginary part could not be set can be set directly via a
new
directly imag overload
See also¶
imag returns the imaginary part
(function template)
real accesses the real part of the complex number
(public member function)
2024.06.10 | http://cppreference.com |