Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The latest version of this topic can be found at error_category Class.
Represents the abstract, common base for objects that describes a category of error codes.
Syntax
class error_category;
Remarks
Two predefined objects implement error_category
: generic_category and system_category.
TypeDefs
value_type | A type that represents the stored error code value. |
Member Functions
default_error_condition | Stores the error code value for an error condition object. |
equivalent | Returns a value that specifies whether error objects are equivalent. |
message | Returns the name of the specified error code. |
name | Returns the name of the category. |
Operators
operator== | Tests for equality between error_category objects. |
operator!= | Tests for inequality between error_category objects. |
operator< | Tests if the error_category object is less than the error_category object passed in for comparison. |
Requirements
Header: <system_error>
Namespace: std
error_category::default_error_condition
Stores the error code value for an error condition object.
virtual error_condition default_error_condition(int _Errval) const;
Parameters
Parameter | Description |
---|---|
_Errval |
The error code value to store in the error_condition. |
Return Value
Returns error_condition(_Errval, *this)
.
Remarks
error_category::equivalent
Returns a value that specifies whether error objects are equivalent.
virtual bool equivalent(value_type _Errval,
const error_condition& _Cond) const;
virtual bool equivalent(const error_code& _Code,
value_type _Errval) const;
Parameters
Parameter | Description |
---|---|
_Errval |
The error code value to compare. |
_Cond |
The error_condition object to compare. |
_Code |
The error_code object to compare. |
Return Value
true
if the category and value are equal; otherwise, false
.
Remarks
The first member function returns *this == _Cond.category() && _Cond.value() == _Errval
.
The second member function returns *this == _Code.category() && _Code.value() == _Errval
.
error_category::message
Returns the name of the specified error code.
virtual string message(error_code::value_type val) const = 0;
Parameters
Parameter | Description |
---|---|
val |
The error code value to describe. |
Return Value
Returns a descriptive name of the error code val
for the category.
Remarks
error_category::name
Returns the name of the category.
virtual const char *name() const = 0;
Return Value
Returns the name of the category as a null-terminated byte string.
Remarks
error_category::operator==
Tests for equality between error_category
objects.
bool operator==(const error_category& right) const;
Parameters
Parameter | Description |
---|---|
right |
The object to be tested for equality. |
Return Value
true if the objects are equal; false if the objects are not equal.
Remarks
This member operator returns this == &right
.
error_category::operator!=
Tests for inequality between error_category
objects.
bool operator!=(const error_category& right) const;
Parameters
Parameter | Description |
---|---|
right |
The object to be tested for inequality. |
Return Value
true if the error_category
object is not equal to the error_category
object passed in right
; otherwise false.
Remarks
The member operator returns (!*this == right)
.
error_category::operator<
Tests if the error_category object is less than the error_category
object passed in for comparison.
bool operator<(const error_category& right) const;
Parameters
Parameter | Description |
---|---|
right |
The error_category object to be compared. |
Return Value
true if the error_category
object is less than the error_category
object passed in for comparison; Otherwise, false.
Remarks
The member operator returns this < &right
.
error_category::value_type
A type that represents the stored error code value.
typedef int value_type;
Remarks
This type definition is a synonym for int
.