Common mathematical functions | |||||||||||||||||||||||||||||||
Mathematical special functions(C++17) | |||||||||||||||||||||||||||||||
Mathematical constants(C++20) | |||||||||||||||||||||||||||||||
Basic linear algebra algorithms(C++26) | |||||||||||||||||||||||||||||||
Data-parallel types (SIMD)(C++26) | |||||||||||||||||||||||||||||||
Floating-point environment(C++11) | |||||||||||||||||||||||||||||||
Complex numbers | |||||||||||||||||||||||||||||||
Numeric array (valarray ) | |||||||||||||||||||||||||||||||
Pseudo-random number generation | |||||||||||||||||||||||||||||||
Bit manipulation(C++20) | |||||||||||||||||||||||||||||||
Saturation arithmetic(C++26) | |||||||||||||||||||||||||||||||
Factor operations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Interpolations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Generic numeric operations | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
C-style checked integer arithmetic | |||||||||||||||||||||||||||||||
|
primary templatestd::complex<T> | ||
(1) | ||
T imag()const; | (until C++14) | |
constexpr T imag()const; | (since C++14) | |
(2) | ||
void imag( T value); | (until C++20) | |
constexprvoid imag( T value); | (since C++20) | |
specializationstd::complex<float> | ||
(1) | ||
float imag()const; | (until C++11) | |
constexprfloat imag()const; | (since C++11) | |
(2) | ||
void imag(float value); | (until C++20) | |
constexprvoid imag(float value); | (since C++20) | |
specializationstd::complex<double> | ||
(1) | ||
double imag()const; | (until C++11) | |
constexprdouble imag()const; | (since C++11) | |
(2) | ||
void imag(double value); | (until C++20) | |
constexprvoid imag(double value); | (since C++20) | |
specializationstd::complex<longdouble> | ||
(1) | ||
longdouble imag()const; | (until C++11) | |
constexprlongdouble imag()const; | (since C++11) | |
(2) | ||
void imag(longdouble value); | (until C++20) | |
constexprvoid imag(longdouble value); | (since C++20) | |
Accesses the imaginary part of the complex number.
Contents |
value | - | the value to set the imaginary part to |
In C++11, overload(1) instd::complex specializations used to be specified withoutconst qualifier. However, in C++11, aconstexpr specifier used in a non-static member function impliesconst, and thus the behavior is as ifconst is specified.
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 newimag overload |
returns the imaginary part (function template)[edit] | |
accesses the real part of the complex number (public member function)[edit] |