# std::error_category

> C++ Atlas: `cppatlas.com/w/cpp/error/error_category` | Source: https://en.cppreference.com/w/cpp/error/error_category | Domain: Diagnostics | Standards: C++11, C++20

std::error_category serves as the base class for specific error category types, such as std::system_category, std::iostream_category, etc.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <system_error>
class error_category; // (since C++11)
```

`std::error_category` serves as the base class for specific error category types, such as `std::system_category`, `std::iostream_category`, etc. Each specific category class defines the `error_code` - `error_condition` mapping and holds the explanatory strings for all error_conditions. The objects of error category classes are treated as singletons, passed by reference.

### Member functions

- (constructor): constructs an `error_category` (public member function)
- (destructor) [virtual]: destructs an `error_category` (virtual public member function)
- `operator=` [deleted]: not copy assignable (public member function)
- `name` [virtual]: obtains the name of the category (virtual public member function)
- `default_error_condition` [virtual]: maps `error_code` to `error_condition` (virtual public member function)
- `equivalent` [virtual]: compares `error_code` and `error_condition` for equivalence (virtual public member function)
- `message` [virtual]: obtains the explanatory string (virtual public member function)
- `operator==`, `operator!=` (removed in C++20), `operator<` (removed in C++20), `operator<=>` (C++20): compares two error categories (function)

### Specific error categories

- `generic_category` (C++11): identifies the generic error category (function)
- `system_category` (C++11): identifies the operating system error category (function)
- `iostream_category` (C++11): identifies the iostream error category (function)
- `future_category` (C++11): identifies the future error category (function)

---
Attribution: content from https://en.cppreference.com/w/cpp/error/error_category (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.