Scroll to navigation

std::operator==,!=,(std::error_code)(3) C++ Standard Libary std::operator==,!=,(std::error_code)(3)

NAME

std::operator==,!=,(std::error_code) - std::operator==,!=,(std::error_code)

Synopsis


Defined in header <system_error>
bool operator==( const std::error_code& lhs, (1) (since C++11)
const std::error_code& rhs ) noexcept;
bool operator!=( const std::error_code& lhs, (2) (since C++11)
const std::error_code& rhs ) noexcept; (until C++20)
bool operator<( const std::error_code& lhs, (3) (since C++11)
const std::error_code& rhs ) noexcept; (until C++20)
std::strong_ordering operator<=>( const std::error_code& lhs, (4) (since C++20)
const std::error_code& rhs ) noexcept;


Compares two error code objects.


1) Compares lhs and rhs for equality.
2) Compares lhs and rhs for equality.
3) Checks whether lhs is less than rhs.
4) Obtains three-way comparison result of lhs and rhs.


The <, <=, >, >=, and != operators are synthesized from operator<=> (since C++20)
and operator== respectively.

Parameters


lhs, rhs - error codes to compare

Return value


1) true if the error category and error value compare equal.
2) true if the error category or error value compare are not equal.
3) true if lhs.category() < rhs.category(). Otherwise, true if lhs.category() ==
rhs.category() && lhs.value() < rhs.value(). Otherwise, false.
4) lhs.category() <=> rhs.category() if it is not std::strong_ordering::equal.
Otherwise, lhs.value() <=> rhs.value().

See also


category obtains the error_category for this error_code
(public member function)
value obtains the value of the error_code
(public member function)
operator==
operator!=
operator< compares error_conditions and error_codes
operator<=> (function)
(removed in C++20)
(removed in C++20)
(C++20)

2022.07.31 http://cppreference.com