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

来自cppreference.com
< cpp‎ | error‎ | error code
 
 
 
 
 
在标头 <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
(函数) [编辑]