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 起)
额外重载 (C++11 起)
定义于头文件 <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) 为所有整数和浮点类型提供了额外的重载,这些类型被视为虚部为零的复数。
(since 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 ) )

参见

访问复数的实部
(公开成员函数)
返回虚部
(函数模板)
C 文档 关于 creal