Rule A18-5-4 (required, implementation, automated)

If a project has sized or unsized version of operator “delete” globally defined, then both sized and unsized versions shall be defined.

Rationale

Since C++14 Language Standard it is allowed to overload both sized and unsized versions of the “delete” operator. Sized version provides more efficient way of memory deallocation than the unsized one, especially when the allocator allocates in size categories instead of storing the size nearby the object.

Example

//% $Id: A18-5-4.cpp 289415 2017-10-04 09:10:20Z piotr.serwa $
#include <cstdlib>
void operator delete(
void* ptr) noexcept // Compliant - sized version is defined

{
std::free(ptr);
}
void operator delete(
void* ptr,

std::size_t size) noexcept // Compliant - unsized version is defined
{
std::free(ptr);
}

See also

none