Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | error‎ | error code
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (C++20)
Dynamic memory management
Program utilities
Coroutine support (C++20)
Variadic functions
Debugging support
(C++26)
Three-way comparison
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)
Elementary string conversions
(C++17)
(C++17)

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

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<=> and operator== respectively.

(since C++20)

[edit] Parameters

lhs, rhs - error codes to compare

[edit] 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().

[edit] See also

obtains the error_category for this error_code
(public member function) [edit]
obtains the value of the error_code
(public member function) [edit]
(removed in C++20)(removed in C++20)(C++20)
compares error_conditions and error_codes
(function) [edit]