According to this reference for operator new:
Global dynamic storage operator functions are special in the standard library:
- Al
Operator new defined in header throws bad_alloc exception (which is declared in the same header) instead of returning NULL when memory allocation is not possible. header also defines
void* operator new (std::size_t size, const std::nothrow_t& nothrow_constant) throw();
variant which does not throw exceptions and placement new variant. Without . All three operator overloads: you get only plain old, NULL-returning operator new
void* operator new (std::size_t size) throw (std::bad_alloc);
void* operator new (std::size_t size, const std::nothrow_t& nothrow_constant) throw();
void* operator new (std::size_t size, void* ptr) throw();
are declared in header. However, some compilers may make them available implicitly, but this is non-standard, and you should not rely on it.