ordinary (1) | void operator delete (void* ptr) throw(); |
---|---|
nothrow (2) | void operator delete (void* ptr, const std::nothrow_t& nothrow_constant) throw(); |
placement (3) | void operator delete (void* ptr, void* voidptr2) throw(); |
ordinary (1) | void operator delete (void* ptr) noexcept; |
---|---|
nothrow (2) | void operator delete (void* ptr, const std::nothrow_t& nothrow_constant) noexcept; |
placement (3) | void operator delete (void* ptr, void* voidptr2) noexcept; |
::operator delete(ptr)
.operator delete
are declared in the global namespace, not within the std namespace.<new>
is included or not.delete
operator always calls the first version of this function exactly once for each of its arguments). But these versions are called automatically by a new-expression if the object construction fails (e.g., if the constructor of an object throws while being constructed by a new-expression with nothrow, the matching operator delete function accepting a nothrow argument is called).operator delete
can be called explicitly as a regular function, but in C++, delete
is an operator with a very specific behavior: An expression with the delete
operator, first calls the appropriate destructor (for class types), and then calls function operator delete
(i.e., this function) to release the storage.void*
.operator new
, and have not yet been released by a previous call to this function.operator new
, and have not yet been released by a previous call to this function.
|
|
MyClass constructed MyClass destroyed |