Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: wordsmithing

...

Code Block
T *p1 = new T; // Throws std::bad_alloc if allocation fails
T *p2 = new (std::nothrow) T; // Returns nullptr if allocation fails

T *p3 = new T[1]; // Throws std::bad_alloc if the allocation fails
T *p4 = new (std::nothrow) T[1]; // Returns nullptr if the allocation fails

In additionFurthermoreoperator new[], a subclass of std::bad_alloc, can  can throw an error of type std::bad_array_new_length if , a subclass of std::bad_alloc, if the size argument passed to new is negative or excessively large.

...