title | description | ms.date | f1_keywords | ||
---|---|---|---|---|---|
<system_error> operators |
Learn more about: <system_error> operators |
3/17/2025 |
|
Tests if the object on the left side of the operator is equal to the object on the right side.
bool operator==(const error_code& left,
const error_condition& right);
bool operator==(const error_condition& left,
const error_code& right);
bool operator==(const error_condition& left,
const error_condition& right);
left
The object to test for equality.
right
The object to test for equality.
true
if the objects are equal; false
if objects are not equal.
This function returns left.category() == right.category() && left.value() == right.value()
.
Tests if the object on the left side of the operator is not equal to the object on the right side.
bool operator!=(const error_code& left, const error_condition& right);
bool operator!=(const error_condition& left, const error_code& right);
bool operator!=(const error_code& left, const error_code& right);
bool operator!=(const error_condition& left, const error_condition& right);
left
The object to test for inequality.
right
The object to test for inequality.
true
if the object passed in left is not equal to the object passed in right
; otherwise false
.
This function returns !(left == right)
.
Tests if an object is less than the object passed in for comparison.
template <class _Enum>
inline bool operator<(
_Enum left,
typename enable_if<is_error_code_enum<_Enum>::value,
const error_code&>::type right);
template <class _Enum>
inline bool operator<(
typename enable_if<is_error_code_enum<_Enum>::value,
const error_code&>::type left, _Enum right);
template <class _Enum>
inline bool operator<(
_Enum left,
typename enable_if<is_error_condition_enum<_Enum>::value,
const error_condition&>::type right);
template <class _Enum>
inline bool operator<(
typename enable_if<is_error_condition_enum<_Enum>::value,
const error_condition&>::type left, _Enum right);
left
The object to compare.
right
The object to compare.
true
if the object passed in left
is less than the object passed in right
; Otherwise, false
.
This function tests the error order.
Inserts an error_code
object into the output stream.
template <class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const error_code& ec);
os
The target output stream.
ec
The error_code
object to output.
A reference to the modified output stream.
This operator does the equivalent of os << ec.category().name() << ':' << ec.value()
.
#include <iostream>
#include <system_error>
int main()
{
std::error_code ec(1234, std::generic_category());
std::cout << ec;
}
generic:1234