# std::regex_error::code

> C++ Atlas: `cppatlas.com/w/cpp/regex/regex_error/code` | Source: https://en.cppreference.com/w/cpp/regex/regex_error/code | Domain: Regular expressions | Standards: C++11

Returns the std::regex_constants::error_type that was passed to the std::regex_error constructor.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <regex>
std::regex_constants::error_type code() const; // (since C++11)
```

Returns the `std::regex_constants::error_type` that was passed to the `std::regex_error` constructor.

### See also

- [`error_type`](https://en.cppreference.com/w/cpp/regex/error_type) (C++11): describes different types of matching errors (typedef)
- [(constructor)](https://en.cppreference.com/w/cpp/regex/regex_error/regex_error): constructs a `regex_error` object (public member function)

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