std::exception_ptr(3cxx)

🌸 std::exception_ptr 🌸

hey bestie πŸ’– welcome to the 3cxx section of the libstdc++ manuals β€” this is the page for std::exception_ptr, and honestly? it's giving "small but mighty." let's get into it πŸ¦‹


✨ NAME ✨

std::exception_ptr β€” an opaque pointer to an arbitrary exception. that's it. that's the whole vibe. πŸ™ˆ


πŸŽ€ SYNOPSIS πŸŽ€

first things first, you gotta pull in the header:

#include <exception>

πŸ‘‘ Public Member Functions πŸ‘‘

  • exception_ptr (const exception_ptr &) noexcept β€” copy constructor, noexcept, so it will never throw at you. slay.
  • exception_ptr (exception_ptr &&__o) noexcept β€” move constructor, also noexcept, takes the __o rvalue reference and does its little move thing. ✨
  • exception_ptr (nullptr_t) noexcept β€” construct one from nullptr_t. yes, noexcept too. πŸ’…
  • const class std::type_info * __cxa_exception_type () const noexcept β€” hands you back a const class std::type_info *. it's const and noexcept, so it's the chill, well-behaved one of the group. 🌈
  • operator bool () const noexcept β€” lets you use an exception_ptr in a boolean context, const and noexcept. vibe check built right in. ⭐
  • exception_ptr & operator= (const exception_ptr &) noexcept β€” copy assignment, noexcept, returns a reference to the exception_ptr. πŸ’œ
  • exception_ptr & operator= (exception_ptr &&__o) noexcept β€” move assignment, noexcept, takes __o and returns a reference. 🧚
  • void swap (exception_ptr &) noexcept β€” swaps with another exception_ptr &, returns void, and yep, noexcept. iconic behavior. πŸŽ€

🫢 Friends 🫢

these are the friend functions, aka the inner circle:

  • bool operator== (const exception_ptr &, const exception_ptr &) β€” takes two const exception_ptr & and gives you back a bool. it's marked noexcept=default. πŸ”₯
  • exception_ptr std::current_exception () noexcept β€” returns an exception_ptr and is noexcept. main character energy, fr fr.
  • template<typename _Ex> exception_ptr std::make_exception_ptr (_Ex) noexcept β€” a template over _Ex that hands you an exception_ptr, and it's noexcept. ✨
  • void std::rethrow_exception (exception_ptr) β€” returns void, takes an exception_ptr. 😭 (yes bestie, it does what the name says)
  • void swap (exception_ptr &__lhs, exception_ptr &__rhs) β€” the free-function swap. returns void, takes __lhs and __rhs, both exception_ptr &. 🌸

heads up bestie: these are not member symbols. i repeat β€” not member symbols.
  • void swap (exception_ptr &__lhs, exception_ptr &__rhs) β€” yeah it's listed here too. same signature, same energy. it's just also living in the related-symbols neighborhood. no cap. πŸ‘‘

🌟 Detailed Description 🌟

okay so here's the tea πŸ“:

an opaque pointer to an arbitrary exception.

the actual name of this type is unspecified, so the alias std::exception_ptr should be used to refer to it. iykyk β€” don't go trying to name the type yourself, just use the alias, bestie. πŸ¦‹


πŸ•°οΈ Since πŸ•°οΈ

  • C++11 (but usable in C++98 as a GCC extension) πŸ’œ

🌈 Author 🌈

Generated automatically by Doxygen for libstdc++ from the source code. (not a human girlie writing this, a whole tool. respect. πŸŽ€)


and that's the page, bestie!! πŸ’– this was the 3cxx manual, brought to you by libstdc++ β€” mwah, go forth and catch those exceptions responsibly πŸ«Άβœ¨πŸ’…

πŸ“¦ where this page comes from