std::bad_alloc
Min standard notice:
Header: <new>
std::bad_alloc is the type of the object thrown as exceptions by the allocation functions to report failure to allocate storage.
# Declarations
class bad_alloc;
# Parameters
other: another exception object to copy
# Return value
*this
# Notes
Implementations are allowed but not required to override what().
# Example
#include <iostream>
#include <new>
int main()
{
try
{
while (true)
{
new int[100000000ul];
}
}
catch (const std::bad_alloc& e)
{
std::cout << "Allocation failed: " << e.what() << '\n';
}
}