Namespaces
Variants

std::complex<T>:: complex

From cppreference.net
Primäre Vorlage ( std:: complex < T > )
(1)
complex ( const T & re = T ( ) , const T & im = T ( ) ) ;
(bis C++14)
constexpr complex ( const T & re = T ( ) , const T & im = T ( ) ) ;
(seit C++14)
(2)
complex ( const complex & other ) ;
(bis C++14)
constexpr complex ( const complex & other ) ;
(seit C++14)
(bis C++23)
constexpr complex ( const complex & other ) = default ;
(seit C++23)
(3)
template < class X >
complex ( const complex < X > & other ) ;
(bis C++14)
template < class X >
constexpr complex ( const complex < X > & other ) ;
(seit C++14)
(bis C++23)
template < class X >
constexpr explicit ( /* siehe unten */ ) complex ( const complex < X > & other ) ;
(seit C++23)
Standard explizite Spezialisierung std:: complex < float > (bis C++23)
(1)
complex ( float re = 0.0f , float im = 0.0f ) ;
(bis C++11)
constexpr complex ( float re = 0.0f , float im = 0.0f ) ;
(seit C++11)
constexpr complex ( const complex < float > & other ) = default ;
(2) (seit C++20)
(3)
explicit complex ( const complex < double > & other ) ;
explicit complex ( const complex < long double > & other ) ;
(bis C++11)
constexpr explicit complex ( const complex < double > & other ) ;
constexpr explicit complex ( const complex < long double > & other ) ;
(seit C++11)
Standard explizite Spezialisierung std:: complex < double > (bis C++23)
(1)
complex ( double re = 0.0 , double im = 0.0 ) ;
(bis C++11)
constexpr complex ( double re = 0.0 , double im = 0.0 ) ;
(seit C++11)
constexpr complex ( const complex < double > & other ) = default ;
(2) (seit C++20)
(3)
complex ( const complex < float > & other ) ;
explicit complex ( const complex < long double > & other ) ;
(bis C++11)
constexpr complex ( const complex < float > & other ) ;
constexpr explicit complex ( const complex < long double > & other ) ;
(seit C++11)
Standard explizite Spezialisierung std:: complex < long double > (bis C++23)
(1)
complex ( long double re = 0.0L, long double im = 0.0L ) ;
(bis C++11)
constexpr complex ( long double re = 0.0L, long double im = 0.0L ) ;
(seit C++11)
constexpr complex ( const complex < long double > & other ) = default ;
(2) (seit C++20)
(3)
complex ( const complex < float > & other ) ;
complex ( const complex < double > & other ) ;
(bis C++11)
constexpr complex ( const complex < float > & other ) ;
constexpr complex ( const complex < double > & other ) ;
(seit C++11)

Konstruiert das std:: complex -Objekt. Die standardmäßigen expliziten Spezialisierungen ( std:: complex < float > , std:: complex < double > und std:: complex < long double > ) haben unterschiedliche Konstruktordeklarationen von der Hauptvorlage. (bis C++23)

1) Konstruiert die komplexe Zahl aus dem Realteil re und dem Imaginärteil im .
2) Kopierkonstruktor. Konstruiert das Objekt mit der Kopie der Inhalte von other . Die Kopierkonstruktoren werden in den standardmäßigen expliziten Spezialisierungen implizit deklariert. (bis C++20)
3) Converting constructor . Konstruiert das Objekt aus einer komplexen Zahl eines anderen Typs.

Die Hauptvorlage stellt einen konvertierenden Konstruktor als Template bereit, während jede Standard-Explizitspezialisierung zwei Nicht-Template-Konstruktoren für die beiden anderen Standard-Explizitspezialisierungen bereitstellt.

Die Nicht-Template-Konstruktoren sind konvertierende Konstruktoren (d.h. nicht explizit) genau dann, wenn die Konvertierungen der Real- und Imaginärteile keine Verengung darstellen.

(bis C++23)

Für die Hauptvorlage ergibt der Ausdruck innerhalb von explicit genau dann false , wenn der Gleitkomma-Konvertierungsrang von T größer oder gleich dem Gleitkomma-Konvertierungsrang von X ist.

(seit C++23)

Parameter

re - der Realteil
im - der Imaginärteil
other - eine andere komplexe Zahl, die als Quelle verwendet wird

Hinweise

Seit C++23 muss der Kopierkonstruktor trivial sein, um die TriviallyCopyable Anforderung zu erfüllen, aber Implementierungen machen ihn in der Regel in allen Modi trivial.

Siehe auch

weist die Inhalte zu
(öffentliche Elementfunktion)
ein std::complex Literal, das eine rein imaginäre Zahl repräsentiert
(Funktion)