命名空间
变体
操作

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

来自 cppreference.cn
< cpp‎ | 错误‎ | 错误码
 
 
 
 
 
定义于头文件 <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
(public member function) [编辑]
获取 error_code 的值
(public member function) [编辑]
(在 C++20 中移除)(在 C++20 中移除)(C++20)
比较 error_conditionerror_code
(function) [编辑]