devxlogo

March 10, 1998

Exceptions and operator new

Standard C++ states that operator new should throw an exception of type std::bad_alloc when it fails. This is different from previous stages of C++ and it means two important things:

Exception specification

A function that may throw an exception can warn its users about that by specifying a list of exceptions it may throw, thus helping its users to catch such exceptions