std::nested_exception(3cxx)
π std::nested_exception
okay bestie, welcome to the cxx corner of the manual β this page is literally called std::nested_exception, and it's about to become your new hyperfixation. it's a mixin class, it's C++11, it's giving "small but essential." let's get into it π«Ά
β¨ SYNOPSIS β¨
first things first, you gotta let it in:
#include <exception>
π Public Member Functions
nested_exception () noexceptβ the default constructor, and she stores the current exception (if any). no cap, that's the whole job πnested_exception (const nested_exception &) noexcept=defaultβ copy constructor, defaulted andnoexcept, iconic behaviour onlyexception_ptr nested_ptr () const noexceptβ access the stored exception, that's it, that's the vibenested_exception & operator= (const nested_exception &) noexcept=defaultβ copy assignment, also defaulted, alsonoexcept, also slayingvoid rethrow_nested () constβ rethrow the stored exception, or terminate if none was stored π (yes, for real, please note that)
πΈ Detailed Description πΈ
so, mixin class that stores the current exception. that's the assignment, and she ate β¨
you use this type via std::throw_with_nested to store the current exception nested within another exception. it's like a little exception inside an exception, matryoshka doll energy, main character and supporting cast πͺπ
Since: C++11 β old enough to be trusted, young enough to be relevant π
See also: std::throw_with_nested β her bestie, her partner in crime, go read that one next π«Ά
π¦ Constructor & Destructor Documentation π¦
std::nested_exception::nested_exception () [inline], [noexcept]
the default constructor. she stores the current exception (if any). if there isn't one, cool, she just vibes. no drama, noexcept girlies don't panic π
π Member Function Documentation π
exception_ptr std::nested_exception::nested_ptr () const [inline], [noexcept]
access the stored exception. that's it. get your exception_ptr, live your life, it's literally that simple π
void std::nested_exception::rethrow_nested () const [inline]
rethrow the stored exception, or terminate if none was stored π this is not a drill, this is the documented behaviour, so check before you call fr fr.
References std::rethrow_exception() and std::terminate() β both linked, both important, iykyk β
bestie note:rethrow_nested()straight-up callsstd::terminate()when nothing was stored. that's a whole program-ending moment, so don't roll up unprepared π
π§ Author π§
generated automatically by Doxygen for libstdc++ from the source code. not me being auto-generated and still having more personality than half the headers out here π β¨
and that's the page, bestie! sign-off time: this little gem is from libstdc++, manual page std::nested_exception(3cxx) β go forth and nest your exceptions responsibly π¦ππ
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms