Namespaces
Variants

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

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

比较两个错误代码对象。

1) 比较 lhs rhs 是否相等。
2) 比较 lhs rhs 是否相等。
3) 检查 lhs 是否小于 rhs
4) 获取 lhs rhs 的三路比较结果。

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

(since C++20)

参数

lhs, rhs - 待比较的错误码

返回值

1) true 当错误类别和错误值比较结果相等时。
2) true 当错误类别或错误值比较不相等时。
3) true lhs. category ( ) < rhs. category ( ) 。否则, true lhs. category ( ) == rhs. category ( ) && lhs. value ( ) < rhs. value ( ) 。否则, false
4) lhs. category ( ) <=> rhs. category ( ) 若其结果不是 std :: strong_ordering :: equal 。否则返回 lhs. value ( ) <=> rhs. value ( )

参见

获取此 error_code 对应的错误类别
(公开成员函数)
获取 error_code 的值
(公开成员函数)
(C++20 中移除) (C++20 中移除) (C++20)
比较 error_condition error_code
(函数)