VMS Help CXXLSTD, Runtime Support, new *Conan The Librarian |
Standard C++ Library NAME new - The new operators (used to allocate dynamic storage in a program) are declared in the header <new>. SYNOPSIS #include <new> void *operator new(size_t n) throw(std::bad_alloc); void *operator new(size_t n, const std::nothrow_t&) throw(); void *operator new(size_t n, void *p) throw(); void *operator new[](size_t n) throw(std::bad_alloc); void *operator new[](size_t n,const std::nothrow_t&) throw(); void *operator new[](size_t n, void *p) throw(); DESCRIPTION void *operator new(size_t n) throw(std::bad_alloc); void *operator new(size_t n, const std::nothrow_t&) throw() These versions of new are called to allocate n bytes of suitably aligned storage to represent an object of that size. A C++ program can define a function with either of these signatures which is intended to replace the implementation provided default provided by the Standard C++ Library. Both return a non-null pointer when memory allocation succeeds. The first function throws bad_alloc on memory allocation failure. The second or nothrow version of operator new returns null on memory allocation failure. void *operator new(size_t n, void *p) throw(); This function is called by a placement new expression which looks like new (p) T, where p is a pointer to an object. The function returns p. void *operator new[](size_t n) throw(std::bad_alloc); void *operator new[](size_t n,const std::nothrow_t&) throw(); The next two functions are called by a new[] expression i.e. by the array form of a new expression. They are called to allocate n bytes of suitably aligned storage to represent an array object of that or smaller size. A C++ program can define a function with either of these signatures which is intended to replace the default implementation provided by the Standard C++ Library. Both return a non-null pointer when memory allocation succeeds. The first function throws bad_alloc on memory allocation failure. The second or nothrow version of operator new returns null on memory allocation failure. void *operator new[](size_t n, void *p) throw(); This function is called by a placement array new expression which looks like new (p) T[n], where p is a pointer to an object. The function returns p. SEE ALSO delete, bad_alloc, no_throw STANDARDS CONFORMANCE ANSI X3J16/ISO WG21 Joint C++ Committee
|