|
|
|
|
Member functions | ||||
Non-member functions | ||||
(until C++20)(until C++20)(C++20) | ||||
Helper classes | ||||
Defined in header <system_error> | ||
class error_condition; | (since C++11) | |
std::error_condition
holds a platform-independent value identifying an error condition. Likestd::error_code, it is uniquely identified by an integer value and astd::error_category, but unlikestd::error_code, the value is not platform-dependent.
A typical implementation holds one integer data member (the value) and a pointer to anstd::error_category.
Contents |
constructs anerror_condition (public member function)[edit] | |
replaces the contents (public member function)[edit] | |
replaces the contents (public member function)[edit] | |
sets theerror_condition to value0 ingeneric_category (public member function)[edit] | |
obtains the value of theerror_condition (public member function)[edit] | |
obtains theerror_category for thiserror_condition (public member function)[edit] | |
obtains the explanatory string (public member function)[edit] | |
checks if the value is non-zero (public member function)[edit] |
(removed in C++20)(removed in C++20)(C++20) | compareserror_condition s anderror_code s(function)[edit] |
(C++11) | identifies an enumeration as anstd::error_condition (class template)[edit] |
hash support forstd::error_condition (class template specialization)[edit] |
Thecomparison between astd::error_code and astd::error_condition
is defined by their error categories. Notably, an error condition ofstd::generic_category may compare equal to an error code of a specific category (e.g.std::system_category), if they represent the same kind of error.
Astd::errc value can be compared to an error code via implicit conversion tostd::error_condition
.
#include <cerrno>#include <iostream>#include <system_error>#include <Windows.h> int main(){std::error_code ec{ERROR_FILE_EXISTS,std::system_category()}; std::error_condition econd{EEXIST,std::generic_category()}; std::cout.setf(std::ios::boolalpha);std::cout<<(ec== econd)<<'\n';// typically truestd::cout<<(ec==std::errc::file_exists)<<'\n';// dittostd::cout<<(ec== make_error_code(std::errc::file_exists))<<'\n';// false:// different category}
Possible output:
truetruefalse
(C++11) | holds a platform-dependent error code (class)[edit] |
(C++11) | base class for error categories (class)[edit] |
creates an error condition for anerrc valuee(function)[edit] |