“cpp/error/error code/operator cmp”的版本间的差异
来自cppreference.com
< cpp | error | error code
小 (1个修订: Translate from the English version) |
小 |
||
(未显示2个用户的5个中间版本) | |||
第1行: | 第1行: | ||
− | + | {{cpp/title|1=operator==,!=,<{{small|(std::error_code)}}}} | |
− | {{cpp/title|1=operator==,!=,<{{small | + | |
{{cpp/error/error_code/navbar}} | {{cpp/error/error_code/navbar}} | ||
− | {{ | + | {{begin}} |
− | {{ | + | {{header|system_error}} |
− | {{ | + | {{|num=1|=c++11|1= |
− | bool operator==( const error_code& lhs, const error_code& rhs ); | + | bool operator==( const error_code& lhs, |
+ | const error_code& rhs ) ; | ||
}} | }} | ||
− | {{ | + | {{|num=|sincec++11|1= |
− | bool operator!=( const error_code& lhs, const error_code& rhs ); | + | bool operator!=( const error_code& lhs, |
+ | const error_code& rhs ) ; | ||
}} | }} | ||
− | {{ | + | {{|num=|sincec++11|1= |
− | bool operator<( const error_code& lhs, const error_code& rhs ); | + | bool operator<( const error_code& lhs, |
+ | const error_code& rhs ) ; | ||
}} | }} | ||
− | {{ | + | {{ |
+ | |||
+ | |||
+ | |||
+ | end}} | ||
− | + | 比较两个错误码对象 | |
− | @1@ | + | @1@ 比较 {{|lhs}} {{|rhs}} 等 |
− | @2@ | + | @2@ 比较 {{|lhs}} {{|rhs}} 等 |
− | @ | + | {{|lhs}} {{|rhs}} |
+ | @@ {{|lhs}} {{|rhs}} | ||
+ | |||
+ | {{| | ||
+ | {{}} | ||
+ | }} | ||
===参数=== | ===参数=== | ||
− | {{ | + | {{begin}} |
− | {{ | + | {{| lhs, rhs | 错误码}} |
− | {{ | + | {{end}} |
===返回值=== | ===返回值=== | ||
− | @1@ | + | @1@ 错误类别和错误值 相等 {{c|true}} |
− | @2@ | + | @2@ 错误类别或错误值比较不相等 {{c|true}} |
− | @3@ | + | @3@ {{c|lhs.category() < rhs.category()}} 则 {{c|true}} {{c|1=lhs.category() == rhs.category() && lhs.value() < rhs.value()}} 则 {{c|}} {{c|}} |
− | + | {{c|lhs.category() <rhs.category()}} {{c|}} {{c|1=lhs.value() <rhs.value()}} | |
− | + | ||
− | + | ||
− | === | + | === === |
− | {{ | + | {{ |
+ | |||
+ | |||
+ | |||
+ | }} | ||
− | + | {{|}} | |
− | {{ | + | |
− | + | ||
− | + |
2023年12月1日 (五) 20:51的最后版本
在标头 <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 的三路比较结果。
|
(C++20 起) |
[编辑] 参数
lhs, rhs | - | 要比较的错误码 |
[编辑] 返回值
1) 若错误类别和错误值比较相等则为 true。
2) 若错误类别或错误值比较不相等则为 true。
3) 若 lhs.category() < rhs.category() 则为 true。否则,若 lhs.category() == rhs.category() && lhs.value() < rhs.value() 则为 true。否则为 false。
4) 若 lhs.category() <=> rhs.category() 不为 std::strong_ordering::equal 则为该值。否则为 lhs.value() <=> rhs.value()。
[编辑] 参阅
获得此 error_code 的 error_category (公开成员函数) | |
获得 error_code 的值 (公开成员函数) | |
(C++20 移除)(C++20 移除)(C++20) |
比较 error_condition 和 error_code (函数) |