std::imag(std::complex)(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

✨ 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 num has a standard (until C++23) floating-point type T, then std::imag(num) has the same effect as std::imag(std::complex<T>(num)).
  • Otherwise, if num has an integer type, then std::imag(num) has the same effect as std::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