operator==,!=,<,<=>(std::error_condition)
来自 cppreference.cn
< cpp | error | error condition
定义于头文件 <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, bool operator==( 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, bool operator==( 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。
|
(自 C++20 起) |
[编辑] 参数
lhs, rhs, cond | - | 要比较的错误条件 |
code | - | 要比较的错误代码 |
[编辑] 返回值
1) 如果错误类别和错误值比较相等,则为 true。
2) 如果错误类别或错误值比较不相等,则为 true。
3) 如果 lhs.category() < rhs.category(),则为 true。否则,如果 lhs.category() == rhs.category() && lhs.value() < rhs.value(),则为 true。否则,false。
4) 如果不是 std::strong_ordering::equal,则为 lhs.category() <=> rhs.category()。否则,为 lhs.value() <=> rhs.value()。
5) 如果 code.category().equivalent(code.value(), cond) 或 cond.category().equivalent(code, cond.value()),则为 true。
6) 如果 code.category().equivalent(code.value(), cond) 和 cond.category().equivalent(code, cond.value()) 都不成立,则为 true。
[编辑] 参见
[虚拟] |
比较 error_code 和 error_condition 的等价性( std::error_category 的虚公共成员函数) |
(在 C++20 中移除)(在 C++20 中移除)(C++20) |
比较两个 error_code (函数) |