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, also noexcept. 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