std::error_category::operator==,!=,<,<=>

来自cppreference.com
 
 
 
 
std::error_category
成员函数
error_category::operator==error_category::operator!=error_category::operator<error_category::operator<=>
(C++20 前)(C++20 前)(C++20)
 
bool operator==( const error_category& rhs ) const noexcept;
(1)(C++11 起)
bool operator!=( const error_category& rhs ) const noexcept;
(2)(C++11 起)
(C++20 前)
bool operator<( const error_category& rhs ) const noexcept;
(3)(C++11 起)
(C++20 前)
std::strong_ordering operator<=>( const error_category& rhs ) const noexcept;
(4)(C++20 起)

与另一错误类别比较。

1) 检查 *thisrhs 是否指代同一对象。
2) 检查 *thisrhs 是否不指代同一对象。
3)this&rhs 的顺序排序 *thisrhs。等价于 std::less<const error_category*>()(this, &rhs)
4)this&rhs 的顺序排序 *thisrhs。等价于 std::std::compare_three_way()(this, &rhs)

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

(C++20 起)

参数

rhs-指定要比较的 error_category

返回值

1)*thisrhs 指代同一对象,则为 true,否则为 false
2)*thisrhs 不指代同一对象,则为 true,否则为 false
3) 若按 this&rhs 的顺序,*this 小于 rhs 则为 true
4) 若按 this&rhs 的顺序,*this 小于 rhs 则为 std::strong_ordering::less,否则若按该顺序 rhs 小于 *this 则为 std::strong_ordering::greater,否则为 std::strong_ordering::equal