std::complex::imag(3)

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

okay so bestie πŸ’– welcome to std::complex::imag(3), the manual page from the C++ Standard Libary (yes, that spelling, leave it alone πŸ’…). This is all about std::complex::imag: accessing the imaginary part of a complex number. Let’s get into it, no cap ✨

🌸 NAME 🌸

std::complex::imag β€” std::complex::imag (iconic, self-titled, periodt πŸ‘‘)

πŸ¦‹ Synopsis πŸ¦‹

ok so here’s the overload fam. The getter is overload (1) and the setter is overload (2) β€” that’s how the page numbers them. The short vibe: imag() with no args gets the imaginary part, and imag(value) sets it 🫢

primary template

primary template
std::complex<T>

T imag() const;                    (until C++14)
constexpr T imag() const;          (since C++14)

void imag( T value );              (until C++20)
constexpr void imag( T value );    (since C++20)

specialization std::complex<float>

specialization
std::complex<float>

float imag() const;                (until C++11)
constexpr float imag() const;      (since C++11)

void imag( float value );          (until C++20)
constexpr void imag( float value ); (since C++20)

specialization std::complex<double>

specialization
std::complex<double>

double imag() const;               (until C++11)
constexpr double imag() const;     (since C++11)

void imag( double value );         (until C++20)
constexpr void imag( double value ); (since C++20)

specialization std::complex<long double>

specialization
std::complex<long double>

long double imag() const;          (until C++11)
constexpr long double imag() const; (since C++11)

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 ✨

  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 LWG 387
    • Applied to C++98
    • Behavior as published the imaginary part could not be set directly
    • Correct behavior can be set directly via a new imag overload

πŸ¦‹ See also πŸ¦‹

  • imag returns the imaginary part (function template)
  • real accesses the real part of the complex number (public member function)

okay that’s the whole vibe, bestie 🫢 this page is from http://cppreference.com, dated 2024.06.10, and its manual tag is std::complex::imag(3). mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from