Difference between revisions of "cpp/memory/new/bad array new length"
m (Text replace - "{{mark c++11 feature}}" to "{{mark since c++11}}") |
(nothing is inherited from bad_alloc) |
||
Line 23: | Line 23: | ||
{{dcl list end}} | {{dcl list end}} | ||
− | {{ | + | {{cpp/memory/new/bad_alloc/inherit}} |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | }} | + | |
− | + | ||
{{cpp/error/exception/exception/inherit}} | {{cpp/error/exception/exception/inherit}} | ||
Line 49: | Line 42: | ||
int small = 1; | int small = 1; | ||
int large = INT_MAX; | int large = INT_MAX; | ||
− | try { | + | try {http://en.cppreference.com/mwiki/skins/common/images/button_nowiki.png |
new int[negative]; // negative size | new int[negative]; // negative size | ||
new int[small]{1,2,3}; // too many initializers | new int[small]{1,2,3}; // too many initializers |
Revision as of 04:56, 28 March 2012
Template:cpp/memory/new/sidebar Template:ddcl list begin <tr class="t-dsc-header">
<td><new>
<td></td> <td></td> </tr> <tr class="t-dcl ">
<td ><td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> Template:ddcl list end
std::bad_array_new_length
is the type of the object thrown as exceptions by the new-expressions 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.
Contents |
Member functions
constructs the bad_array_new_length object (public member function) |
Inherited from std::bad_alloc
Template:cpp/error/exception/exception/inherit
Notes
The override for the virtual member function what()
may by provided, but is not required.