std::experi...~scope_fail(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

okay so bestie, this is the std::experi...~scope_fail(3) page from the C++ Standard Libary manual β€” yes, we are in the C++ corner of the group chat. It’s all about the destructor std::experimental::scope_fail::~scope_fail, and it’s short, sweet, and lowkey giving cleanup main character energy. πŸ’…

πŸ’– NAME πŸ’–

std::experimental::scope_fail::~scope_fail β€” that’s the whole name, and then it literally repeats itself: std::experimental::scope_fail::~scope_fail. It’s giving β€œI said what I said” energy, and honestly? Iconic. ✨

✨ Synopsis ✨

~scope_fail() noexcept;  (library fundamentals TS v3)

So this destructor is noexcept. When it runs, it calls the exit function if the result of std::uncaught_exceptions() is greater than the counter of uncaught exceptions β€” typically on stack unwinding β€” and the scope_fail is active. Then it destroys the stored EF (if it is a function object) and any other non-static data members. Cleanup slay, fr fr. πŸ§ΉπŸ’…

πŸ¦‹ Notes πŸ¦‹

Here’s the vibe check: whether the destructor is called on stack unwinding can be detected by the comparison of the result of std::uncaught_exceptions() and the counter of uncaught exceptions in the scope_fail. That’s literally the detection mechanism, no cap. πŸ‘€

🌈 See also 🌈

  • release β€” makes the scope_fail inactive (public member function). Obsessed with a clean exit? This is your girl. 🫢

xoxo, your Unix bestie πŸŽ€ β€” source/version: http://cppreference.com, dated 2024.06.10, and the page title was std::experi...~scope_fail(3). Periodt. πŸ’–

πŸ“¦ where this page comes from