std::imag(std::complex)(3)
β¨ NAME β¨
std::imag(std::complex) β yep, that's the name, and the NAME line is literally std::imag(std::complex) - std::imag(std::complex) π
. This page comes from the C++ Standard Libary manual (yes bestie, that's the manual name, typo and all π), and it's all about the imaginary-part moves for std::complex.
πΈ Synopsis πΈ
okay so here's the synopsis, and yes it's giving template realness β¨. Defined in header <complex>:
Defined in header <complex>
template< class T >
T imag( const std::complex<T>& z ); (until C++14)
template< class T >
constexpr T imag( const std::complex<T>& z ); (since C++14)
Additional overloads (since C++11) β also defined in header <complex> π«Ά:
Defined in header <complex>
float imag( float f );
double imag( double f ); (until C++14)
long double imag( long double f );
constexpr float imag( float f ); (1)
constexpr double imag( double f ); (since C++14)
(until C++23)
(A)
constexpr long double imag( long double f );
template< class FloatingPoint >
FloatingPoint imag( FloatingPoint f ); (since C++23)
template< class Integer >
double imag( Integer i ); (until C++14)
template< class Integer >
constexpr double imag( Integer i ); (B)
(since C++14)
Number 1) is the main-character overload: it returns the imaginary part of the complex number z, i.e. z.imag() π
.
A,B) are the extra-overload squad: additional overloads are provided for all integer and floating-point types, and those get treated as complex numbers with zero imaginary part. (The additional-overload era starts since C++11, iykyk.)
π¦ Parameters π¦
zβ complex value πfβ floating-point value β¨iβ integer value π
π Return value π
- 1) The imaginary part of
z. - A)
decltype(f){}(zero). - B)
0.0.
π§ Notes π§
The additional overloads are not required to be provided exactly as (A,B) β they only need to be sufficient to ensure that for their argument num:
- If
numhas a standard (until C++23) floating-point typeT, thenstd::imag(num)has the same effect asstd::imag(std::complex<T>(num)). - Otherwise, if
numhas an integer type, thenstd::imag(num)has the same effect asstd::imag(std::complex<double>(num)).
π See also π
imagβ accesses the imaginary part of the complex number (public member function)realβ returns the real part (function template)- C documentation for
cimag
okay that's the page, bestie π«Ά. Source/version check: http://cppreference.com, dated 2024.06.10, and the page id is std::imag(std::complex)(3). Byeee π
β¨
π¦ 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