18 Language support library [language.support]

18.6 Dynamic memory management [support.dynamic]

18.6.1 Storage allocation and deallocation [new.delete]

18.6.1.2 Array forms [new.delete.array]

void* operator new[](std::size_t size);

Effects: The allocation function ([basic.stc.dynamic.allocation]) called by the array form of a new-expression ([expr.new]) to allocate size bytes of storage suitably aligned to represent any array object of that size or smaller.227

Replaceable: a C++ program can define a function with this function signature that displaces the default version defined by the C++ standard library.

Required behavior: Same as for operator new(std::size_t). This requirement is binding on a replacement version of this function.

Default behavior: Returns operator new(size).

void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;

Effects: Same as above, except that it is called by a placement version of a new-expression when a C++ program prefers a null pointer result as an error indication, instead of a bad_alloc exception.

Replaceable: a C++ program can define a function with this function signature that displaces the default version defined by the C++ standard library.

Required behavior: Return a non-null pointer to suitably aligned storage ([basic.stc.dynamic]), or return a null pointer. This requirement is binding on a replacement version of this function.

Default behavior: Calls operator new[](size). If the call returns normally, returns the result of that call. Otherwise, returns a null pointer.

void operator delete[](void* ptr) noexcept;

Effects: The deallocation function ([basic.stc.dynamic.deallocation]) called by the array form of a delete-expression to render the value of ptr invalid.

Replaceable: a C++ program can define a function with this function signature that displaces the default version defined by the C++ standard library.

Requires: ptr shall be a null pointer or its value shall be the value returned by an earlier call to operator new[](std::size_t) or operator new[](std::size_t,const std::nothrow_t&) which has not been invalidated by an intervening call to operator delete[](void*).

Requires: If an implementation has strict pointer safety ([basic.stc.dynamic.safety]) then ptr shall be a safely-derived pointer.

Default behavior: Calls operator delete(ptr).

void operator delete[](void* ptr, const std::nothrow_t&) noexcept;

Effects: The deallocation function ([basic.stc.dynamic.deallocation]) called by the implementation to render the value of ptr invalid when the constructor invoked from a nothrow placement version of the array new-expression throws an exception.

Replaceable: a C++ program may define a function with this function signature that displaces the default version defined by the C++ standard library.

Requires: If an implementation has strict pointer safety ([basic.stc.dynamic.safety]) then ptr shall be a safely-derived pointer.

Default behavior: calls operator delete[](ptr).

It is not the direct responsibility of operator new[](std::size_t) or operator delete[](void*) to note the repetition count or element size of the array. Those operations are performed elsewhere in the array new and delete expressions. The array new expression, may, however, increase the size argument to operator new[](std::size_t) to obtain space to store supplemental information.