std::bad_optional_access - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::bad_optional_access

From cppreference.com
< cpp‎ | utility‎ | optional

Defined in header `<optional>` |  |
class bad_optional_access; |  | (since C++17)

Defines a type of object to be thrown by `std::optional::value` when accessing an optional object that does not contain a value.

Inheritance diagram

### [edit] Member functions

(constructor) | constructs the exception object (public member function) [edit]

## Inherited from std::exception

### Member functions

(destructor) [virtual] | destructs the exception object (virtual public member function of `std::exception`) [edit]
what [virtual] | returns an explanatory string (virtual public member function of `std::exception`) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/utility/optional/bad_optional_access&oldid=91294"