std::bad_array_new_length
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Definido no cabeçalho <new>
|
||
class bad_array_new_length; |
(desde C++11) | |
std::bad_array_new_length
is the type of the object thrown as exceptions by the novos-expressões 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.
Índice |
[editar] Funções de membro
constrói o objeto 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. (função pública membro) |
Herdado de std::bad_alloc
Herdado de std::exception
Member functions
[virtual] |
destrói o objeto de exceção 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. (of std::exception função pública virtual membro)
|
[virtual] |
retorna uma cadeia explicativa 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. (of std::exception função pública virtual membro)
|
[editar] Notas
The override for the virtual member function what()
may by provided, but is not required.
[editar] Exemplo
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'; } }
[editar] Veja também
funções de alocação 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. (função) | |
exceção lançada quando a alocação de memória falha 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) |