Namespaces
Variants

std:: islessgreater

From cppreference.net
Common mathematical functions
Nearest integer floating point operations
(C++11)
(C++11)
(C++11) (C++11) (C++11)
Floating point manipulation functions
(C++11) (C++11)
(C++11)
(C++11)
Classification and comparison
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
islessgreater
(C++11)
Types
(C++11)
(C++11)
(C++11)
Macro constants
定义于头文件 <cmath>
(1)
bool islessgreater ( float x, float y ) ;

bool islessgreater ( double x, double y ) ;

bool islessgreater ( long double x, long double y ) ;
(C++11 起)
(C++23 前)
constexpr bool islessgreater ( /* 浮点类型 */ x,
/* 浮点类型 */ y ) ;
(C++23 起)
定义于头文件 <cmath>
template < class Arithmetic1, class Arithmetic2 >
bool islessgreater ( Arithmetic1 x, Arithmetic2 y ) ;
(A) (C++11 起)
(C++23 起为 constexpr)
1) 判断浮点数 x 是否小于或大于浮点数 y ,且不触发浮点异常。 该库为所有无cv限定符的浮点类型提供了参数 x y 的重载版本。 (since C++23)
A) 为所有其他算术类型的组合提供了额外的重载。

目录

参数

x, y - 浮点数或整数值

返回值

x < y || x > y 时返回 true ,否则返回 false

注释

内置的 operator < operator > 对于浮点数,若一个或两个参数为 NaN 时可能引发 FE_INVALID 。此函数是表达式 x < y || x > y 的“静默”版本。

额外的重载不需要完全按照 (A) 的形式提供。只需确保对于它们的第一个参数 num1 和第二个参数 num2 满足以下条件:

  • num1 num2 具有 long double 类型,则 std :: islessgreater ( num1, num2 ) std :: islessgreater ( static_cast < long double > ( num1 ) ,
    static_cast < long double > ( num2 ) )
    效果相同。
  • 否则,若 num1 和/或 num2 具有 double 类型或整数类型,则 std :: islessgreater ( num1, num2 ) std :: islessgreater ( static_cast < double > ( num1 ) ,
    static_cast < double > ( num2 ) )
    效果相同。
  • 否则,若 num1 num2 具有 float 类型,则 std :: islessgreater ( num1, num2 ) std :: islessgreater ( static_cast < float > ( num1 ) ,
    static_cast < float > ( num2 ) )
    效果相同。
(C++23 前)

num1 num2 具有算术类型,则 std :: islessgreater ( num1, num2 ) std :: islessgreater ( static_cast < /*common-floating-point-type*/ > ( num1 ) ,
static_cast < /*common-floating-point-type*/ > ( num2 ) )
效果相同,其中 /*common-floating-point-type*/ num1 num2 类型之间具有最高 浮点转换等级 和最高 浮点转换子等级 的浮点类型,整数类型的实参被认为具有与 double 相同的浮点转换等级。

若不存在具有最高等级和子等级的此类浮点类型,则 重载决议 不会从提供的重载中得到可用候选。

(C++23 起)

参见

(C++11)
检查第一个浮点参数是否小于第二个
(函数)
(C++11)
检查第一个浮点参数是否大于第二个
(函数)
C 文档 for islessgreater