std::exception(3)
π std::exception β NAME π
std::exception β the base class for all library exceptions. Like, the OG. The mother of every throw you've ever panic-written at 3am. This page lives in the Library Functions Manual section (3), iykyk π«Ά
β¨ SYNOPSIS β¨
#include <exception>
πΈ Inherited by
Bestie, the docs literally list these as inherited-by, and four of the entries came through completely blank in the source β so here's exactly what's there, gaps and all:
- (blank)
- (blank)
- (blank)
- (blank)
__gnu_cxx::forced_error__gnu_cxx::recursive_init_errorstd::bad_allocstd::bad_caststd::bad_exceptionstd::bad_function_call
π Public Member Functions
_GLIBCXX26_CONSTEXPR exception(const exception &)=defaultβ copy constructor, defaulted, no notes π_GLIBCXX26_CONSTEXPR exception(exception &&)=defaultβ move constructor, also defaulted, also iconic_GLIBCXX26_CONSTEXPR exception & operator=(const exception &)=defaultβ copy assignment, defaulted_GLIBCXX26_CONSTEXPR exception & operator=(exception &&)=defaultβ move assignment, defaultedvirtual constexpr const char * what() const noexceptβ the one member function that actually does something π¦
π Detailed Description π
Base class for all library exceptions.
Okay so real talk: this is the base class for all exceptions thrown by the standard library, and by certain language expressions. That's a lot of responsibility for one little class. Main character energy, honestly.
And here's the freeing part β you are free to:
- derive your own exception classes π
- use a different hierarchy entirely (go off, build your own kingdom) π°
- throw non-class data (like, e.g., fundamental types) π
No cap, the standard library is not the boss of you.
π₯ 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. That's it, that's the job. It's giving "explain yourself in C-string form" π
Reimplemented in:
std::bad_allocstd::bad_caststd::bad_exceptionstd::bad_function_callstd::bad_typeidstd::bad_weak_ptrstd::experimental::filesystem::v1::filesystem_errorstd::experimental::fundamentals_v1::bad_any_caststd::filesystem::filesystem_errorstd::future_errorstd::ios_base::failurestd::logic_errorstd::runtime_error
Lowkey every single one of them said "not me inheriting what() and doing nothing with it" and then went and overrode it anyway. Respect. π«Ά
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. Not a human, just a very diligent robot β¨
And that's the whole page, bestie β footer said libstdc++ (that's the source/version, courtesy of the libstdc++ manual itself, with the standard std::exception(3) running header up top). No date on this one, so don't come for me. Study it, love it, override what() responsibly. Periodt. π
ππ
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms