STD::COMPLEX(3cxx)
π std::complex< _Tp > β the manual page, but make it cute (3cxx)
Okay bestie, so this is the std::complex< _Tp > page from the libstdc++ manual, section 3cxx β the whole complex-numbers situation, the template, all of it. Grab a strawberry π and let's go.
β¨ NAME β¨
std::complex< _Tp > β the template that represents complex numbers, and honestly? iconic.
π¦ SYNOPSIS π¦
#include <complex>
πΈ Public Types πΈ
typedef _Tp value_typeβ the Value typedef, i.e. the type that holds your actual real-and-imaginary numbers. π
π Public Member Functions π
constexpr complex (const _Tp &__r=_Tp(), const _Tp &__i=_Tp())β the Default constructor. First parameter is x, second parameter is y. Unspecified parameters default to 0. (So like, pick me energy: if you don't pass anything it's just0and0.)constexpr complex (const complex &)=defaultβ the copy constructor, defaulted, no notes. β¨template<typename _Up > constexpr complex (const complex< _Up > &__z)β the Converting constructor. Glow-up from a different_Uptype. π¦constexpr complex __rep () constβ internal representation accessor, literally right there in the list._GLIBCXX_ABI_TAG_CXX11 constexpr _Tp imag () constβ gives you the imaginary part back. πconstexpr void imag (_Tp __val)β sets the imaginary part to__val.constexpr complex< _Tp > & operator*= (const _Tp &)β Multiply this complex number by a scalar. Slay.template<typename _Up > constexpr complex< _Tp > & operator*= (const complex< _Up > &)β Multiply this complex number by another. Two icons colliding. π₯constexpr complex< _Tp > & operator+= (const _Tp &__t)β Add a scalar to this complex number.template<typename _Up > constexpr complex< _Tp > & operator+= (const complex< _Up > &)β Add another complex number to this one.constexpr complex< _Tp > & operator-= (const _Tp &__t)β Subtract a scalar from this complex number.template<typename _Up > constexpr complex< _Tp > & operator-= (const complex< _Up > &)β Subtract another complex number from this one.constexpr complex< _Tp > & operator/= (const _Tp &)β Divide this complex number by a scalar.template<typename _Up > constexpr complex< _Tp > & operator/= (const complex< _Up > &)β Divide this complex number by another.constexpr complex< _Tp > & operator= (const _Tp &)β Assign a scalar to this complex number.constexpr complex & operator= (const complex &)=defaultβ the defaulted copy assignment. Periodt.template<typename _Up > constexpr complex< _Tp > & operator= (const complex< _Up > &)β Assign another complex number to this one._GLIBCXX_ABI_TAG_CXX11 constexpr _Tp real () constβ gives you the real part back. π«Άconstexpr void real (_Tp __val)β sets the real part to__val.
π Detailed Description π
So, template<typename _Tp> ... class std::complex< _Tp > β Template to represent complex numbers. That's the whole vibe.
Specializations for float, double, and long double are part of the library. Results with any other type are not guaranteed β so like, don't come for the library with some random custom type and then act surprised, bestie. π
β Parameters β
- Tp β Type of real and imaginary values.
π§ Member Typedef Documentation π§
π template<typename _Tp > typedef _Tp std::complex< _Tp >::value_type
Value typedef. That's it, that's the whole entry. π
β¨ Constructor & Destructor Documentation β¨
π template<typename _Tp > constexpr std::complex< _Tp >::complex (const _Tp & __r = _Tp(), const _Tp & __i = _Tp()) [inline], [constexpr]
Default constructor. First parameter is x, second parameter is y. Unspecified parameters default to 0. Yes both of them. Lowkey generous. π
π¦ template<typename _Tp > template<typename _Up > constexpr std::complex< _Tp >::complex (const complex< _Up > & __z) [inline], [constexpr]
Converting constructor. That's the whole description, no cap.
π₯ Member Function Documentation π₯
πΈ template<typename _Tp > constexpr complex< _Tp > & std::complex< _Tp >::operator+= (const _Tp & __t) [inline], [constexpr]
Add a scalar to this complex number. Simple. Effective. Ate.
πΈ template<typename _Tp > constexpr complex< _Tp > & std::complex< _Tp >::operator-= (const _Tp & __t) [inline], [constexpr]
Subtract a scalar from this complex number. Same energy, opposite direction. β¨
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. Not a human, not a vibe, just a doc generator doing its thing. π€
Heads up bestie: that "Results with any other type are not guaranteed" line is the real warning here βfloat,double, andlong doubleare the guaranteed ones, fr fr.
And that's the page! π This was the std::complex< _Tp >(3cxx) manual entry, shipped under the libstdc++ banner β that's the source/version sitch, and the page carries that 3cxx tag. No date on this one, so don't @ me. Byeee! π
πβ¨
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms