Namespaces
Variants

operator==,!=,<,<=> (std::error_condition)

From cppreference.net
Utilities library
定义于头文件 <system_error>
bool operator == ( const std:: error_condition & lhs,
const std:: error_condition & rhs ) noexcept ;
(1) (C++11 起)
bool operator ! = ( const std:: error_condition & lhs,
const std:: error_condition & rhs ) noexcept ;
(2) (C++11 起)
(C++20 前)
bool operator < ( const std:: error_condition & lhs,
const std:: error_condition & rhs ) noexcept ;
(3) (C++11 起)
(C++20 前)
std:: strong_ordering operator <=> ( const std:: error_condition & lhs,
const std:: error_condition & rhs ) noexcept ;
(4) (C++20 起)
bool operator == ( const std:: error_code & code,
const std:: error_condition & cond ) noexcept ;
(5) (C++11 起)
bool operator == ( const std:: error_condition & cond,
const std:: error_code & code ) noexcept ;
(5) (C++11 起)
(C++20 前)
bool operator ! = ( const std:: error_code & code,
const std:: error_condition & cond ) noexcept ;
(6) (C++11 起)
(C++20 前)
bool operator ! = ( const std:: error_condition & cond,
const std:: error_code & code ) noexcept ;
(6) (C++11 起)
(C++20 前)

比较两个错误条件。

1) 检查 lhs rhs 是否相等。
2) 检查 lhs rhs 是否不相等。
3) 检查 lhs 是否 小于 rhs
4) 获取 lhs rhs 的三路比较结果。
5) 检查 code 是否为 cond 的语义匹配。
6) 检查 code 是否与 cond 不构成语义匹配。

< <= > >= != 运算符分别由 operator <=> operator == 自动合成。

(since C++20)

参数

lhs, rhs, cond - 待比较的错误条件
code - 待比较的错误代码

返回值

1) true 当错误类别和错误值比较结果相等时。
2) true 当错误类别或错误值比较不相等时。
3) true 如果 lhs. category ( ) < rhs. category ( ) 。否则,当 lhs. category ( ) == rhs. category ( ) && lhs. value ( ) < rhs. value ( ) 时返回 true 。否则返回 false
4) lhs. category ( ) <=> rhs. category ( ) 如果其结果不是 std :: strong_ordering :: equal 。否则返回 lhs. value ( ) <=> rhs. value ( )
5) code. category ( ) . equivalent ( code. value ( ) , cond ) cond. category ( ) . equivalent ( code, cond. value ( ) ) 成立时返回 true
6) true 当且仅当 code. category ( ) . equivalent ( code. value ( ) , cond ) cond. category ( ) . equivalent ( code, cond. value ( ) ) 均不成立。

参见

[virtual]
比较 error_code error_condition 的等价性
( std::error_category 的虚公开成员函数)
(C++20 中移除) (C++20 中移除) (C++20)
比较两个 error_code
(函数)