std::bad_alloc - cppreference.com
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>
| Elemento definito nell'header <new> |
||
|
|
||
std::bad_alloc is the type of the object thrown as exceptions by the
to report failure to allocate storage.
Inheritance diagram
Membri funzioni
| constructs the bad_alloc object (metodo pubblico) | |
| replaces a bad_alloc object (metodo pubblico) | |
restituisce stringa esplicativa Original: returns explanatory string The text has been machine-translated via Google Translate. (metodo pubblico) | |
Inherited from std::exception
Member functions
distrugge l'oggetto eccezione Original: destructs the exception object The text has been machine-translated via Google Translate. (metodo pubblico virtuale) [modifica] | |
restituisce una stringa esplicativa Original: returns an explanatory string The text has been machine-translated via Google Translate. (metodo pubblico virtuale) [modifica] | |
Esempio
#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