Namespaces
Variants

std:: real (std::complex)

From cppreference.net
ヘッダーで定義 <complex>
(1)
template < class T >
T real ( const std:: complex < T > & z ) ;
(C++14まで)
template < class T >
constexpr T real ( const std:: complex < T > & z ) ;
(C++14から)
ヘッダーで定義 <complex>
(A)
float real ( float f ) ;

double real ( double f ) ;

long double real ( long double f ) ;
(C++14まで)
constexpr float real ( float f ) ;

constexpr double real ( double f ) ;

constexpr long double real ( long double f ) ;
(C++14から)
(C++23まで)
template < class FloatingPoint >
constexpr FloatingPoint real ( FloatingPoint f ) ;
(C++23から)
(B)
template < class Integer >
double real ( Integer i ) ;
(C++14まで)
template < class Integer >
constexpr double real ( Integer i ) ;
(C++14から)
1) 複素数の実部を返します z 、すなわち z. real ( )
A,B) すべての整数型および浮動小数点型に対して追加のオーバーロードが提供されており、これらは虚数部がゼロの複素数として扱われます。
(C++11以降)

目次

パラメータ

z - 複素数値
f - 浮動小数点値
i - 整数値

戻り値

1) z の実部。
A) f .
B) static_cast < double > ( i ) .

注記

追加のオーバーロードは (A,B) と厳密に同じ形式で提供される必要はありません。それらは引数 num に対して以下を保証するのに十分であればよいのです:

  • num 標準 (C++23まで) 浮動小数点型 T を持つ場合、 std :: real ( num ) std :: real ( std:: complex < T > ( num ) ) と同じ効果を持つ。
  • それ以外の場合、 num が整数型を持つ場合、 std :: real ( num ) std :: real ( std:: complex < double > ( num ) ) と同じ効果を持つ。

関連項目

複素数の実部にアクセスする
(public member function)
虚部を返す
(function template)