We recommend using Visual Studio 2017

error_category Class

 

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.

class error_category;

Two predefined objects implement error_category: generic_category and system_category.

TypeDefs

value_typeA type that represents the stored error code value.

Member Functions

default_error_conditionStores the error code value for an error condition object.
equivalentReturns a value that specifies whether error objects are equivalent.
messageReturns the name of the specified error code.
nameReturns 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.

Header: <system_error>

Namespace: std

Stores the error code value for an error condition object.

virtual error_condition default_error_condition(int _Errval) const;

Parameters

ParameterDescription
_ErrvalThe error code value to store in the error_condition.

Return Value

Returns error_condition(_Errval, *this).

Remarks

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

ParameterDescription
_ErrvalThe error code value to compare.
_CondThe error_condition object to compare.
_CodeThe 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.

Returns the name of the specified error code.

virtual string message(error_code::value_type val) const = 0;

Parameters

ParameterDescription
valThe error code value to describe.

Return Value

Returns a descriptive name of the error code val for the category.

Remarks

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

Tests for equality between error_category objects.

bool operator==(const error_category& right) const;

Parameters

ParameterDescription
rightThe 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.

Tests for inequality between error_category objects.

bool operator!=(const error_category& right) const;

Parameters

ParameterDescription
rightThe 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).

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

ParameterDescription
rightThe 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.

A type that represents the stored error code value.

typedef int value_type;

Remarks

This type definition is a synonym for int.

<system_error>

Show: