std::complex<T>::complex
Primary template (std::complex<T>) |
||
(1) | ||
complex(
const T& re = T(
), const T& im = T(
)
)
;
|
(until C++14) | |
constexpr complex(
const T& re = T(
), const T& im = T(
)
)
;
|
(since C++14) | |
(2) | ||
complex( const complex& other ); |
(until C++14) | |
constexpr complex( const complex& other );
|
(since C++14) (until C++23) |
|
constexpr complex(
const complex& other )
=
default
;
|
(since C++23) | |
(3) | ||
template
<
class X >
complex( const complex<X> & other ) ; |
(until C++14) | |
template
<
class X >
constexpr complex( const complex<X> & other ) ; |
(since C++14) (until C++23) |
|
template
<
class X >
constexpr explicit ( /* see below */ ) complex( const complex<X> & other ) ; |
(since C++23) | |
Standard explicit specialization std::complex<float>
(until C++23)
|
||
(1) | ||
complex(
float re =
0.0f, float im =
0.0f
)
;
|
(until C++11) | |
constexpr complex(
float re =
0.0f, float im =
0.0f
)
;
|
(since C++11) | |
constexpr complex(
const complex<
float
>
& other )
=
default
;
|
(2) | (since C++20) |
(3) | ||
explicit complex(
const complex<
double
>
& other )
;
explicit complex( const complex< long double > & other ) ; |
(until C++11) | |
constexpr
explicit complex(
const complex<
double
>
& other )
;
constexpr explicit complex( const complex< long double > & other ) ; |
(since C++11) | |
Standard explicit specialization std::complex<double>
(until C++23)
|
||
(1) | ||
complex(
double re =
0.0, double im =
0.0
)
;
|
(until C++11) | |
constexpr complex(
double re =
0.0, double im =
0.0
)
;
|
(since C++11) | |
constexpr complex(
const complex<
double
>
& other )
=
default
;
|
(2) | (since C++20) |
(3) | ||
complex(
const complex<
float
>
& other )
;
explicit complex( const complex< long double > & other ) ; |
(until C++11) | |
constexpr complex(
const complex<
float
>
& other )
;
constexpr explicit complex( const complex< long double > & other ) ; |
(since C++11) | |
Standard explicit specialization
std::complex
<
long
double
>
(until C++23)
|
||
(1) | ||
complex(
long
double re = 0.0L, long
double im = 0.0L )
;
|
(until C++11) | |
constexpr complex(
long
double re = 0.0L, long
double im = 0.0L )
;
|
(since C++11) | |
constexpr complex(
const complex<
long
double
>
& other )
=
default
;
|
(2) | (since C++20) |
(3) | ||
complex(
const complex<
float
>
& other )
;
complex( const complex< double > & other ) ; |
(until C++11) | |
constexpr complex(
const complex<
float
>
& other )
;
constexpr complex( const complex< double > & other ) ; |
(since C++11) | |
Constructs the std::complex object. The standard explicit specializations (std::complex<float>, std::complex<double> and std::complex < long double > (until C++23)
The main template provides a converting constructor template, while each standard explicit specialization provides two non-template constructors for the two other standard explicit specializations. The non-template constructors are converting constructors (i.e. non-explicit) if and only if the conversions of the real and imaginary parts are not narrowing. |
(until C++23) |
For the main template, the expression inside explicit evaluates to false if and only if the floating-point conversion rank of |
(since C++23) |
Parameters
re | - | the real part |
im | - | the imaginary part |
other | - | another complex number to use as source |
Notes
Since C++23, the copy constructor is required to be trivial in order to satisfy the TriviallyCopyable
See also
assigns the contents (public member function) |
|
a std::complex literal representing purely imaginary number (function) |
|
C documentation for CMPLX
|