public virtual member function

std::error_category::equivalent

<system_error>
(1)
virtual bool equivalent (int valcode, const error_condition& cond) const noexcept;
(2)
virtual bool equivalent (const error_code& code, int valcond) const noexcept;
Check error code equivalence
Checks whether, for the category, an error code is equivalent to an error condition.

This function is called by the global overloads of comparison operators when an error_condition object is compared to an error_code object to check for equality or inequality. If either one of those objects' categories considers the other equivalent using this function, they are considered equivalent by the operator.

Its definition in the base class error_category is equivalent to:
1
2
3
4
virtual bool equivalent (int valcode, const error_condition& cond) const noexcept
{ return default_error_condition(valcode) == cond; }
virtual bool equivalent (const error_code& code, int valcond) const noexcept
{ return *this==code.category && code.value()==valcond; }


As a virtual member function, this behavior can be overriden in derived classes to define a different correspondence mechanism for each error_category type.

Two error_category objects can be compared directly, using its relational operators member functions.

Parameters

code
An object of an error_code type.
cond
An object of an error_condition type.
valcode
A numerical value identifying an error code.
valcond
A numerical value identifying an error condition.
If the error_category object is the one returned by generic_category, this value corresponds to one of the values defined in <cerrno>.

Return value

true if the arguments are considered equivalent.
false otherwise.

See also