Skip to content

Search topics & cppreference

Search all study topics, concept maps, and 6,587 C++ and C reference pages.

std::error_code

std::error_code represents a platform-dependent error code value.

NotebookLM
Defined in header <system_error>
class error_code;
(since C++11)

std::error_code represents a platform-dependent error code value. Each std::error_code object holds an error code value originating from the operating system or some low-level interface and a pointer to an object of type std::error_category, which corresponds to the said interface. The error code values are not required to be unique across different error categories.

Member functions

constructs an error code
(public member function)
assigns another error code
(public member function)
assigns another error code
(public member function)
Modifiers
sets the error_code to value ​0​ in system_category
(public member function)
Observers
obtains the value of the error_code
(public member function)
obtains the error_category for this error_code
(public member function)
obtains the error_condition for this error_code
(public member function)
obtains the explanatory string for this error_code
(public member function)
checks if the value is non-zero
(public member function)

Non-member functions

(removed in C++20)(removed in C++20)(C++20)
compares two error_codes
(function)
outputs the value and the category name to an output stream
(function)

Helper classes

identifies a class as an error_code enumeration
(class template)
hash support for std::error_code
(class template specialization)

See also

holds a portable error code
(class)
base class for error categories
(class)
creates error code value for errc enum e
(function)

Content from this page on cppreference.com, licensed under CC-BY-SA 3.0 and GFDL. Modified: restyled, site navigation removed, code windows added. Offline snapshot of 9 February 2025.