std::complex<T>
is a class template which most notably supports:
- storage/access of Cartesian components, via
real()
andimag()
- arithmetic between complex numbers, via its operator overloads
- overloads of mathematical functions, such as
std::sqrt(std::complex)
- used-defined literals such as
3.0i
for initializing imaginary numbers - interoperability with C's
_Complex
types
It is a type with value semantics, meaning that copying it and passing std::complex<T>
between functions behaves identically to fundamental types like float
.