std:: get (std::complex)
From cppreference.net
|
定義済みヘッダー
<complex>
|
||
|
template
<
std::
size_t
I
>
friend constexpr T & get ( std:: complex < T > & x ) ; |
(1) | (C++26以降) |
|
template
<
std::
size_t
I
>
friend constexpr const T & get ( const std:: complex < T > & x ) ; |
(2) | (C++26以降) |
|
template
<
std::
size_t
I
>
friend constexpr T && get ( std:: complex < T > && x ) ; |
(3) | (C++26以降) |
|
template
<
std::
size_t
I
>
friend constexpr const T && get ( const std:: complex < T > && x ) ; |
(4) | (C++26以降) |
complex
から実部または虚部への参照を返します。これはそれぞれ
I
==
0
または
I
==
1
の場合に対応します。主に構造化バインディングのサポートのために提供されています。
目次 |
パラメータ
| x | - |
a
complex
|
戻り値
1-4)
格納されているものから実部または虚部への参照を、
I
==
0
または
I
==
1
の場合にそれぞれ返す。
注記
| 機能テスト マクロ | 値 | 標準 | 機能 |
|---|---|---|---|
__cpp_lib_tuple_like
|
202311L
|
(C++26) | std::complex にタプルプロトコルを追加 |
例
このコードを実行
#include <complex> static_assert([z = std::complex(1.0, 2.0)] { #if __cpp_lib_tuple_like >= 202311L return std::get<0>(z) == 1.0 and std::get<1>(z) == 2.0; #else return z.real() == 1.0 and z.imag() == 2.0; #endif }()); int main() {}
関連項目
| 構造化バインディング (C++17) | 指定された名前を初期化子のサブオブジェクトまたはタプルの要素にバインドする |
|
(C++11)
|
タプルの指定された要素にアクセスする
(関数テンプレート) |
|
(C++11)
|
pair
の要素にアクセスする
(関数テンプレート) |
|
(C++11)
|
array
の要素にアクセスする
(関数テンプレート) |