Namespaces
Variants

std::complex<T>:: complex

From cppreference.net
プライマリテンプレート ( std:: complex < T > )
(1)
complex ( const T & re = T ( ) , const T & im = T ( ) ) ;
(C++14まで)
constexpr complex ( const T & re = T ( ) , const T & im = T ( ) ) ;
(C++14以降)
(2)
complex ( const complex & other ) ;
(C++14まで)
constexpr complex ( const complex & other ) ;
(C++14から)
(C++23まで)
constexpr complex ( const complex & other ) = default ;
(C++23から)
(3)
template < class X >
complex ( const complex < X > & other ) ;
(C++14まで)
template < class X >
constexpr complex ( const complex < X > & other ) ;
(C++14から)
(C++23まで)
template < class X >
constexpr explicit ( /* see below */ ) complex ( const complex < X > & other ) ;
(C++23から)
標準明示的特殊化 std:: complex < float > (C++23まで)
(1)
complex ( float re = 0.0f , float im = 0.0f ) ;
(C++11まで)
constexpr complex ( float re = 0.0f , float im = 0.0f ) ;
(C++11以降)
constexpr complex ( const complex < float > & other ) = default ;
(2) (C++20以降)
(3)
explicit complex ( const complex < double > & other ) ;
explicit complex ( const complex < long double > & other ) ;
(C++11まで)
constexpr explicit complex ( const complex < double > & other ) ;
constexpr explicit complex ( const complex < long double > & other ) ;
(C++11以降)
標準明示的特殊化 std:: complex < double > (C++23まで)
(1)
complex ( double re = 0.0 , double im = 0.0 ) ;
(C++11まで)
constexpr complex ( double re = 0.0 , double im = 0.0 ) ;
(C++11以降)
constexpr complex ( const complex < double > & other ) = default ;
(2) (C++20以降)
(3)
complex ( const complex < float > & other ) ;
explicit complex ( const complex < long double > & other ) ;
(C++11まで)
constexpr complex ( const complex < float > & other ) ;
constexpr explicit complex ( const complex < long double > & other ) ;
(C++11以降)
標準明示的特殊化 std:: complex < long double > (C++23まで)
(1)
complex ( long double re = 0.0L, long double im = 0.0L ) ;
(C++11まで)
constexpr complex ( long double re = 0.0L, long double im = 0.0L ) ;
(C++11以降)
constexpr complex ( const complex < long double > & other ) = default ;
(2) (C++20以降)
(3)
complex ( const complex < float > & other ) ;
complex ( const complex < double > & other ) ;
(C++11まで)
constexpr complex ( const complex < float > & other ) ;
constexpr complex ( const complex < double > & other ) ;
(C++11以降)

std:: complex オブジェクトを構築します。 標準の明示的特殊化 ( std:: complex < float > , std:: complex < double > および std:: complex < long double > ) は、主テンプレートとは異なるコンストラクタ宣言を持ちます。 (C++23まで)

1) 実部 re と虚部 im から複素数を構築します。
2) コピーコンストラクタ。オブジェクトを other の内容のコピーで構築します。 コピーコンストラクタは標準明示的特殊化において暗黙的に宣言されます。 (C++20まで)
3) Converting constructor . 異なる型の複素数からオブジェクトを構築します。

メインテンプレートは変換コンストラクタテンプレートを提供し、各標準明示的特殊化は他の2つの標準明示的特殊化に対する2つの非テンプレートコンストラクタを提供します。

非テンプレートコンストラクタは、実部と虚部の変換が縮小変換でない場合に限り、変換コンストラクタ(すなわち非explicit)となります。

(C++23まで)

メインテンプレートについて、 explicit 内の式は、 T 浮動小数点変換ランク X の浮動小数点変換ランク以上である場合に限り false と評価されます。

(C++23以降)

パラメータ

re - 実数部
im - 虚数部
other - ソースとして使用する別の複素数

注記

C++23以降、コピーコンストラクタは trivial であることが要求されるようになりました( TriviallyCopyable 要件を満たすため)。ただし、実装では一般的に全てのモードでtrivialとなるようにされています。

関連項目

内容を代入する
(公開メンバ関数)
純虚数を表す std::complex リテラル
(関数)