std::nested_exception(3)
π¦ std::nested_exception(3) π¦
okay bestie, pull up a chair, because today we're talking about a Library Functions Manual page that is lowkey one of the most underrated little gems in libstdc++ β std::nested_exception. she's a mixin, she's nosy, she remembers things. let's get into it. π
β¨ NAME β¨
std::nested_exception β the little mixin class that stores the current exception for you, no cap π
πΈ SYNOPSIS πΈ
First things first, you gotta let her in the door:
#include <exception>
π Public Member Functions π
nested_exception () noexceptβ the default constructor, and she is thriving. she stores the current exception (if any). if there isn't one? she just vibes.nested_exception (const nested_exception &) noexcept=defaultβ the copy constructor, defaulted,noexcept, iconic behavior honestly.exception_ptr nested_ptr () const noexceptβ your girl lets you access the stored exception. it's giving personal assistant energy.nested_exception & operator= (const nested_exception &) noexcept=defaultβ assignment operator, also defaulted, alsonoexcept. consistent queen. πvoid rethrow_nested () constβ she rethrows the stored exception, or β and this is the dramatic part β terminates if none was stored. so like. she WILL end the whole program. respect her. π
π Detailed Description π
So what is she, fr fr? she's a mixin class that stores the current exception. that's the whole bit. that's her job.
The way you actually use her is through std::throw_with_nested, which lets you store the current exception nested within another exception. it's like those little russian dolls but make it error handling. πͺβ¨
Since C++11 π (yes she's been around, she's a classic)
See also std::throw_with_nested β her bestie, her partner in crime π«Ά
π§ Constructor & Destructor Documentation π§
π std::nested_exception::nested_exception () [inline], [noexcept] π
The default constructor stores the current exception (if any). that's it, that's the whole constructor. she's simple, she's efficient, she's [inline] and [noexcept] and she knows it. β¨
References std::current_exception() β that's where she's pulling the tea from, iykyk. π΅
β Member Function Documentation β
π exception_ptr std::nested_exception::nested_ptr () const [inline], [noexcept] π
Access the stored exception. that's the whole thing. she's [inline], she's [noexcept], she hands you the exception_ptr and says nothing else. mysterious. elegant. obsessed. π
π₯ void std::nested_exception::rethrow_nested () const [inline] π₯
Rethrow the stored exception, or terminate if none was stored.
β οΈ bestie listen β if there's nothing stored, she calls std::terminate(). that is NOT a drill. your program is done. no recovery, no catching, just vibes and consequences. π
she's [inline], she's const, she does not play.
References std::rethrow_exception(), rethrow_nested(), and std::terminate() β yes, she references herself, that's just her main character energy π
Referenced by rethrow_nested() β okay so she's referencing herself AND being referenced by herself. truly her own biggest fan. we love a self-sufficient icon. π
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. so nobody wrote this by hand, the robots did it, and honestly? they ate. π€β¨
okay that's the whole page bestie, you're officially fluent in std::nested_exception. this page came to you straight from the libstdc++ girlies, and no date was printed on this one so we're just gonna say whenever this shipped π°οΈ β go forth and nest your exceptions responsibly. mwah. ππ¦πΈ
π¦ 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