“cpp/error/error code/operator cmp”的版本间的差异
来自cppreference.com
< cpp | error | error code
小 |
|||
第2行: | 第2行: | ||
{{cpp/error/error_code/navbar}} | {{cpp/error/error_code/navbar}} | ||
{{dcl begin}} | {{dcl begin}} | ||
− | {{dcl header | system_error}} | + | {{dcl header|system_error}} |
− | {{dcl | num=1 | since=c++11 | 1= | + | {{dcl|num=1|since=c++11|1= |
bool operator==( const std::error_code& lhs, | bool operator==( const std::error_code& lhs, | ||
const std::error_code& rhs ) noexcept; | const std::error_code& rhs ) noexcept; | ||
}} | }} | ||
− | {{dcl | num=2 | since=c++11 | until=c++20 | 1= | + | {{dcl|num=2|since=c++11|until=c++20|1= |
bool operator!=( const std::error_code& lhs, | bool operator!=( const std::error_code& lhs, | ||
const std::error_code& rhs ) noexcept; | const std::error_code& rhs ) noexcept; | ||
}} | }} | ||
− | {{dcl | num=3 | since=c++11 | until=c++20 | 1= | + | {{dcl|num=3|since=c++11|until=c++20|1= |
bool operator<( const std::error_code& lhs, | bool operator<( const std::error_code& lhs, | ||
const std::error_code& rhs ) noexcept; | const std::error_code& rhs ) noexcept; | ||
}} | }} | ||
− | {{dcl | num=4 | since=c++20 | 1= | + | {{dcl|num=4|since=c++20|1= |
std::strong_ordering operator<=>( const std::error_code& lhs, | std::strong_ordering operator<=>( const std::error_code& lhs, | ||
const std::error_code& rhs ) noexcept; | const std::error_code& rhs ) noexcept; | ||
第21行: | 第21行: | ||
{{dcl end}} | {{dcl end}} | ||
− | 比较 | + | 比较 个 对象。 |
− | @1@ 比较 {{ | + | @1@ 比较 {{|lhs}} 与 {{|rhs}} 的相等性。 |
− | @2@ 比较 {{ | + | @2@ 比较 {{|lhs}} 与 {{|rhs}} 的相等性。 |
− | @3@ 检查 {{ | + | @3@ 检查 {{|lhs}} 是否小于 {{|rhs}}。 |
− | @4@ 获得 {{ | + | @4@ 获得 {{|lhs}} 与 {{|rhs}} 的三路比较结果。 |
{{rrev | since=c++20 | | {{rrev | since=c++20 | | ||
第34行: | 第34行: | ||
===参数=== | ===参数=== | ||
{{par begin}} | {{par begin}} | ||
− | {{par | lhs, rhs | 要比较的 | + | {{par | lhs, rhs | 要比较的 }} |
{{par end}} | {{par end}} | ||
===返回值=== | ===返回值=== | ||
− | @1@ 若错误类别和错误值比较相等则为 {{c|true}} | + | @1@ 若错误类别和错误值比较相等则为 {{c|true}}。 |
− | @2@ 若错误类别或错误值比较不相等则为 {{c|true}} | + | @2@ 若错误类别或错误值比较不相等则为 {{c|true}}。 |
− | @3@ 若 {{c|lhs.category() < rhs.category()}} 则为 {{c|true}} | + | @3@ 若 {{c|lhs.category() < rhs.category()}} 则为 {{c|true}}。否则,若 {{c|1=lhs.category() == rhs.category() && lhs.value() < rhs.value()}} 则为 {{c|true}}。否则为 {{c|false}} |
− | @4@ 若 {{c|1=lhs.category() <=> rhs.category()}} 不为 {{c|std::strong_ordering::equal}} 则为该值。否则为 {{c|1=lhs.value() <=> rhs.value()}} | + | @4@ 若 {{c|1=lhs.category() <=> rhs.category()}} 不为 {{c|std::strong_ordering::equal}} 则为该值。否则为 {{c|1=lhs.value() <=> rhs.value()}}。 |
===参阅=== | ===参阅=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc inc | cpp/error/error_code/dsc category}} | + | {{dsc inc|cpp/error/error_code/dsc category |
+ | |||
+ | }} | ||
{{dsc end}} | {{dsc end}} | ||
{{langlinks|de|en|es|fr|it|ja|pt|ru}} | {{langlinks|de|en|es|fr|it|ja|pt|ru}} |
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 (函数) |