std::bad_array_new_length
![]() |
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. |
Elemento definito nell'header <new>
|
||
class bad_array_new_length; |
(dal C++11) | |
std::bad_array_new_length
is the type of the object thrown as exceptions by the nuove-espressioni to report invalid array lengths if
1) array length is negative
2) total size of the new array would exceed implementation-defined maximum value
3) the number of initializer-clauses exceeds the number of elements to initialize
Only the first array dimension may generate this exception; dimensions other than the first are constant expressions and are checked at compile time.
Indice |
[modifica] Membri funzioni
costruisce l'oggetto bad_array_new_length Original: constructs the bad_array_new_length objectThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) |
Inherited from std::bad_alloc
Inherited from std::exception
Member functions
[virtuale] |
distrugge l'oggetto eccezione Original: destructs the exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico virtuale) |
[virtuale] |
restituisce una stringa esplicativa Original: returns an explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico virtuale) |
[modifica] Note
The override for the virtual member function what()
may by provided, but is not required.
[modifica] Esempio
Three conditions where std::bad_array_new_length should be thrown:
#include <iostream> #include <new> #include <climits> int main() { int negative = -1; int small = 1; int large = INT_MAX; try { new int[negative]; // negative size new int[small]{1,2,3}; // too many initializers new int[large][1000000]; // too large } catch(const std::bad_array_new_length &e) { std::cout << e.what() << '\n'; } }
[modifica] Vedi anche
allocazione funzioni Original: allocation functions The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione) | |
Eccezione generata quando allocazione memoria fallisce Original: exception thrown when memory allocation fails The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe) |