std::bad_alloc(3cxx)

πŸ’– NAME πŸ’–

std::bad_alloc β€” the exception that might get thrown by new, bestie. This is the 3cxx manual page for it, and yes, she's a whole vibe. 🫢


✨ SYNOPSIS ✨

#include <new>

She inherits std::exception. πŸ’…

She is inherited by std::bad_array_new_length. Family tree slay. 🌈

πŸŽ€ Public Member Functions πŸŽ€

  • bad_alloc (const bad_alloc &)=default β€” copy constructor, defaulted, iconic.
  • bad_alloc & operator= (const bad_alloc &)=default β€” copy assignment, defaulted, also iconic.
  • virtual const char * what () const throw () β€” virtual, and it tells you what's up. πŸ”₯

🌸 Detailed Description 🌸

So, exception possibly thrown by new. That's the whole mood. 😭

bad_alloc (or classes derived from it) is used to report allocation errors from the throwing forms of new. Lowkey serious business. πŸ’€


πŸ¦‹ Member Function Documentation πŸ¦‹

⭐ virtual const char * std::bad_alloc::what () const [virtual] ⭐

Returns a C-style character string describing the general cause of the current error. That's it, that's the function. ✨

Reimplemented from std::exception. Periodt. πŸ‘‘


🧚 Author 🧚

Generated automatically by Doxygen for libstdc++ from the source code. No cap, the robots wrote this one. πŸ€–πŸ’–


Okay bestie, cute lil sign-off: this page is from the libstdc++ manual, and the footer says libstdc++ and std::bad_alloc(3cxx) β€” no date on this one, so don't come for me. πŸ«ΆπŸ’œβ­

πŸ“¦ where this page comes from