“cpp/error/error code/operator cmp”的版本间的差异

来自cppreference.com
< cpp‎ | error‎ | error code
(1个修订: Translate from the English version)
 
(未显示2个用户的5个中间版本)
第1行: 第1行:
{{tr_note}}
+
{{cpp/title|1=operator==,!=,<{{small|(std::error_code)}}}}
{{cpp/title|1=operator==,!=,<{{small|{{tr|(性病:: ERROR_CODE)|(std::error_code)}}}}}}
+
 
{{cpp/error/error_code/navbar}}
 
{{cpp/error/error_code/navbar}}
{{ddcl list begin}}
+
{{begin}}
{{ddcl list header | system_error}}
+
{{header|system_error}}
{{ddcl list item | num=1 | notes={{mark since c++11}} | 1=
+
{{|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 ) ;
 
}}
 
}}
{{ddcl list item | num=1 | notes={{mark since c++11}} | 1=
+
{{|num=|sincec++11|1=
bool operator!=( const error_code& lhs, const error_code& rhs );
+
bool operator!=( const error_code& lhs,
 +
const error_code& rhs ) ;
 
}}
 
}}
{{ddcl list item | num=1 | notes={{mark since c++11}} | 1=
+
{{|num=|sincec++11|1=
bool operator<( const error_code& lhs, const error_code& rhs );
+
bool operator<( const error_code& lhs,
 +
const error_code& rhs ) ;
 
}}
 
}}
{{ddcl list end}}
+
{{
 +
 +
 +
 +
end}}
  
{{tr| 比较两个错误 码对象.|Compares two error code objects.}}
+
比较两个错误码对象
  
@1@ {{tr| 比较{{tt|lhs}} {{tt|rhs}} .|Compares {{tt|lhs}} and {{tt|rhs}} for equality.}}
+
@1@ 比较 {{|lhs}} {{|rhs}} 等
@2@ {{tr| 比较{{tt|lhs}} {{tt|rhs}} .|Compares {{tt|lhs}} and {{tt|rhs}} for equality.}}
+
@2@ 比较 {{|lhs}} {{|rhs}} 等
@3@ {{tr|检查是否{{tt|lhs}} 小于{{tt|rhs}}. |Checks whether {{tt|lhs}} is less than {{tt|rhs}}. }}
+
{{|lhs}} {{|rhs}}
 +
@@ {{|lhs}} {{|rhs}}
 +
 
 +
{{|
 +
{{}}
 +
}}
  
 
===参数===
 
===参数===
{{param list begin}}
+
{{begin}}
{{param list item | lhs, rhs |{{tr| 错误 进行比较| error codes to compare}}}}
+
{{| lhs, rhs |  错误码}}
{{param list end}}
+
{{end}}
  
 
===返回值===
 
===返回值===
@1@ {{tr|{{c|true}}如果 错误类别和错误值相等 的}}|{{c|true}} if the error category and error value compare equal}}.}}
+
@1@ 错误类别和错误值 相等 {{c|true}}
@2@ {{tr|{{c|true}}如果 错误类别或错误值比较 ,是 不相等}}|{{c|true}} if the error category or error value compare are not equal}}}}
+
@2@ 错误类别或错误值比较不相等 {{c|true}}
@3@ {{tr|{{c|true}}{{c|lhs.category() < rhs.category()}} 。否 {{c|true}}{{c|1=lhs.category() == rhs.category() && lhs.value() < rhs.value()}} 。否 {{c|false}}|{{c|true}} if {{c|lhs.category() < rhs.category()}}. Otherwise, {{c|true}} if {{c|1=lhs.category() == rhs.category() && lhs.value() < rhs.value()}}. Otherwise, {{c|false}}}}
+
@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()}}
===例外===
+
{{noexcept}}
+
  
=== 例外===
+
=== ===
{{noexcept}}
+
{{
 +
 +
 +
 +
}}
  
===另请参阅===
+
{{|}}
{{dcl list begin}}
+
{{dcl list template | cpp/error/error_code/dcl list category}}
+
{{dcl list end}}
+

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) 比较 lhsrhs 的相等性。
2) 比较 lhsrhs 的相等性。
3) 检查 lhs 是否小于 rhs
4) 获得 lhsrhs 的三路比较结果。

<<=>>=!= 运算符分别从 operator<=>operator== 合成

(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_conditionerror_code
(函数) [编辑]