STD::COMPLEX(3)

๐Ÿ’– NAME ๐Ÿ’–

std::complex< _Tp > โ€” the glow-up class template that holds your imaginary bestie right next to your real one ๐Ÿซถ


โœจ SYNOPSIS โœจ

#include <complex>

๐ŸŒธ Public Types ๐ŸŒธ

  • typedef _Tp value_type โ€” the value typedef, aka the receipt for what type your numbers actually are ๐Ÿ’…

๐Ÿฆ‹ Public Member Functions ๐Ÿฆ‹

  • constexpr complex (const _Tp &__r=_Tp(), const _Tp &__i=_Tp()) โ€” the default constructor, bestie. First parameter is x, second parameter is y. Whatever you don't pass in defaults to 0. no cap.
  • constexpr complex (const complex &)=default
  • constexpr complex __rep () const
  • template<typename _Up> explicit (!requires(_Up __u) { _Tp{__u};}) const expr complex(const complex< _Up > &__z) โ€” the converting constructor ๐Ÿ‘€
  • constexpr _Tp imag () const
  • constexpr void imag (_Tp __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 one ๐Ÿ”ฅ
  • 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
  • template<typename _Up> constexpr complex< _Tp > & operator= (const complex< _Up > &) โ€” assign another complex number to this one ๐Ÿ’–
  • constexpr _Tp real () const
  • constexpr void real (_Tp __val)

๐ŸŒˆ Detailed Description ๐ŸŒˆ

template<typename _Tp>
    class std::complex< _Tp >

Template to represent complex numbers. it's giving math but make it iconic ๐Ÿงฎโœจ

Specializations for float, double, and long double are part of the library. Results with any other type are not guaranteed โ€” so like, don't try to be different with your _Tp 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 vibe ๐Ÿ’…


๐ŸŒธ Constructor & Destructor Documentation ๐ŸŒธ

template<typename _Tp> 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. lowkey the easiest way to manifest a complex number ๐Ÿซถ

Referenced by operator*=(), operator*=(), operator+=(), operator-=(), operator/=(), operator/=(), operator=(), and operator=().


โญ Member Function Documentation โญ

template<typename _Tp> template<typename _Up> std::complex< _Tp >::explicit
    (!requires(_Up __u) { _Tp{__u};} ) const & [inline]

Converting constructor. she converts, she's flexible, she's main character energy โœจ


template<typename _Tp> complex< _Tp > & std::complex< _Tp >::operator*=
    (const _Tp & ) [constexpr]

Multiply this complex number by a scalar.

References complex().


template<typename _Tp> template<typename _Up> complex< _Tp > & std::complex<
    _Tp >::operator*= (const complex< _Up > & ) [constexpr]

Multiply this complex number by another.

References complex().


template<typename _Tp> complex< _Tp > & std::complex< _Tp >::operator+=
    (const _Tp & __t) [inline],  [constexpr]

Add a scalar to this complex number. plus one bestie, literally ๐Ÿซถ


template<typename _Tp> template<typename _Up> complex< _Tp > & std::complex<
    _Tp >::operator+= (const complex< _Up > & ) [constexpr]

Add another complex number to this one.

References complex().


template<typename _Tp> complex< _Tp > & std::complex< _Tp >::operator-=
    (const _Tp & __t) [inline],  [constexpr]

Subtract a scalar from this complex number.


template<typename _Tp> template<typename _Up> complex< _Tp > & std::complex<
    _Tp >::operator-= (const complex< _Up > & ) [constexpr]

Subtract another complex number from this one.

References complex().


template<typename _Tp> complex< _Tp > & std::complex< _Tp >::operator/=
    (const _Tp & ) [constexpr]

Divide this complex number by a scalar.

References complex().


template<typename _Tp> template<typename _Up> complex< _Tp > & std::complex<
    _Tp >::operator/= (const complex< _Up > & ) [constexpr]

Divide this complex number by another.

References complex().


template<typename _Tp> complex< _Tp > & std::complex< _Tp >::operator=
    (const _Tp & ) [constexpr]

Assign a scalar to this complex number.

References complex().


template<typename _Tp> template<typename _Up> complex< _Tp > & std::complex<
    _Tp >::operator= (const complex< _Up > & ) [constexpr]

Assign another complex number to this one.

References complex().


๐Ÿ’œ Author ๐Ÿ’œ

Generated automatically by Doxygen for libstdc++ from the source code. not a human author, just a robot doing her little tasks, and honestly? she ate ๐Ÿ”ฅ


okay that's the whole page bestie, you're officially fluent in std::complex< _Tp > โ€” this was libstdc++'s version of std::complex< _Tp >(3) and it's giving date night with the compiler, periodt ๐Ÿ’–โœจ๐ŸŽ€ no cap, go forth and be imaginary ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 ยท GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 ยท GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms