Not using below thing anywhere but still this question was in my mind for long.
void* operator new (size_t size)
{
// distort `size` to other value
return malloc(size);
}
Having know that above may not be a well-defined behavior for overloaded new
(say if the size
is decreased), Why doesn't standard force compilers to make it as void* operator new (const size_t);
?
The same can be argued for operator delete
also, where it should void operator delete (void* const);
(adding const
to avoid pointer getting changed).