std::complex::real(3)
π std::complex::real(3) β C++ Standard Library
okay so bestie, welcome to std::complex::real(3), straight out of the C++ Standard Library π¦ this one's all about touching the real part of a complex number β getting it, setting it, the whole vibe. no cap, it's shorter than it looks, the synopsis is just doing the most with its column wrapping π
β¨ SYNOPSIS β¨
heads up bestie, this synopsis is a whole mood board of overloads β every "until"/"since" tag is doing important work, so read them π
πΈ primary template β std::complex<T>
T real() const; (until C++14)
constexpr T real() const; (since C++14)
void real( T value ); (until C++20)
constexpr void real( T value ); (since C++20)
π specialization β std::complex<float>
float real() const; (until C++11)
constexpr float real() const; (since C++11)
void real( float value ); (until C++20)
constexpr void real( float value ); (since C++20)
π¦ specialization β std::complex<double>
(1) double real() const; (until C++11)
(2) constexpr double real() const; (since C++11)
(1) void real( double value ); (until C++20)
(2) constexpr void real( double value ); (since C++20)
π specialization β std::complex<long double>
(1) long double real() const; (until C++11)
(2) constexpr long double real() const; (since C++11)
(1) void real( long double value ); (until C++20)
(2) constexpr void real( long double value ); (since C++20)
π DESCRIPTION
Accesses the real part of the complex number. that's it, that's the whole job, and it does it iconically β¨
- Returns the real part.
- Sets the real part to
value.
π PARAMETERS
valueβ the value to set the real part to π
β RETURN VALUE
- The real part of
*this. - (none) β yeah, the setter's giving nothing back, and honestly? valid.
π§ NOTES
so in C++11, overload (1) in std::complex specializations used to be specified without the const qualifier π but plot twist β 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. the vibe check passed either way, no cap π«Ά
π₯ Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards. retroactive glow-ups, we love to see it π
LWG 387, applied to C++98 β behavior as published: the real part could not be set directly; correct behavior: can be set directly via a newrealoverload πβ‘οΈπ
π SEE ALSO
realβ returns the real part (function template)imagβ accesses the imaginary part of the complex number (public member function)
and that's the page, bestie!! ππ go forth and set your real parts directly, you absolute main character π
courtesy of http://cppreference.com, version 2024.06.10 β mwah, xoxo π
β¨
π¦ 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