[optional.bad.access]

# 22 General utilities library [[utilities]](./#utilities)

## 22.5 Optional objects [[optional]](optional#bad.access)

### 22.5.6 Class bad_optional_access [optional.bad.access]

namespace std {class bad_optional_access : public exception {public:// see [[exception]](exception "17.9.3 Class exception") for the specification of the special member functionsconstexpr const char* what() const noexcept override; };}

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L5018)

The class bad_optional_access defines the type of objects thrown as exceptions to report the situation where an attempt is made to access the value of an optional object that does not contain a value[.](#1.sentence-1)

[ð](#lib:what,bad_optional_access)

`constexpr const char* what() const noexcept override;
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L5027)

*Returns*: An implementation-defined ntbs,
which during constant evaluation is encoded with
the ordinary literal encoding ([[lex.ccon]](lex.ccon "5.13.3 Character literals"))[.](#2.sentence-1)
