---
name: "std::exception"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::exception"
---

# std::exception(3)

Base class for all library exceptions.

## NAME

std::exception - Base class for all library exceptions.

## SYNOPSIS

\#include \<exception\>

Inherited by , , , , **\_\_gnu\_cxx::forced\_error**, **\_\_gnu\_cxx::recursive\_init\_error**, **std::bad\_alloc**, **std::bad\_cast**, **std::bad\_exception**, and **std::bad\_function\_call**.

### Public Member Functions

\_GLIBCXX26\_CONSTEXPR **exception** (const exception &)=default\
 \_GLIBCXX26\_CONSTEXPR **exception** (exception &&)=default\
 \_GLIBCXX26\_CONSTEXPR exception & **operator=** (const exception &)=default\
 \_GLIBCXX26\_CONSTEXPR exception & **operator=** (exception &&)=default\
 virtual constexpr const char \* **what** () const noexcept\

## Detailed Description

Base class for all library exceptions.

This is the base class for all exceptions thrown by the standard library, and by certain language expressions. You are free to derive your own exception classes, or use a different hierarchy, or to throw non-class data (e.g., fundamental types).

## Member Function Documentation

### virtual constexpr const char \* std::exception::what () const \[inline\], \[constexpr\], \[virtual\], \[noexcept\]

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

Reimplemented in **std::bad\_alloc**, **std::bad\_cast**, **std::bad\_exception**, **std::bad\_function\_call**, **std::bad\_typeid**, **std::bad\_weak\_ptr**, **std::experimental::filesystem::v1::filesystem\_error**, **std::experimental::fundamentals\_v1::bad\_any\_cast**, **std::filesystem::filesystem\_error**, **std::future\_error**, **std::ios\_base::failure**, **std::logic\_error**, and **std::runtime\_error**.

## Author

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