---
name: "std::bad_optional_access"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::bad_optional_access"
---

# std::bad\_optional\_access(3cxx)

Exception class thrown when a disengaged optional object is dereferenced.

## NAME

std::bad\_optional\_access - Exception class thrown when a disengaged optional object is dereferenced.

## SYNOPSIS

`#include <optional>`

Inherits **std::exception**.

### Public Member Functions

const char \* **what** () const noexcept **override**\

## Detailed Description

Exception class thrown when a disengaged optional object is dereferenced.

## Member Function Documentation

### const char \* std::bad\_optional\_access::what () const` [inline]`, ` [override]`, ` [virtual]`, ` [noexcept]`

Returns a C-style character string describing the general cause of the current error. \

Reimplemented from **std::exception**.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
