std::bad_alloc – cppreference.com
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>
| definiert in Header <new> |
||
|
|
||
std::bad_alloc is the type of the object thrown as exceptions by the
to report failure to allocate storage.
Inheritance diagram
Member-Funktionen
| constructs the bad_alloc object (öffentliche Elementfunktion) | |
| replaces a bad_alloc object (öffentliche Elementfunktion) | |
kehrt erklärende String Original: returns explanatory string The text has been machine-translated via Google Translate. (öffentliche Elementfunktion) | |
Inherited from std::exception
Member functions
Zerstört das Ausnahme-Objekt Original: destructs the exception object The text has been machine-translated via Google Translate. (virtuellen öffentlichen Member-Funktion of std::exception) [edit]
| |
gibt einen erläuternden String Original: returns an explanatory string The text has been machine-translated via Google Translate. (virtuellen öffentlichen Member-Funktion of std::exception) [edit]
| |
Beispiel
#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'; } }
Output:
Allocation failed: std::bad_alloc