Does delete ptr differ from operator delete(ptr) only in this, that delete calls ptr destructor? Or in other words, does delete ptr first call a destructor of ptr and then operator delete(ptr) to free allocated memory? Then is delete ptr technically equivalent to the following:
T * ptr = new T;
//delete ptr equivalent:
ptr->~T();
::operator delete(static_cast<void *>(ptr));
?
delete ptrwill do overload resolution foroperator delete, so it may not call the global::operator deleteBut otherwise, yes. The
deleteoperator calls the relevant destructor, if any, and then callsoperator delete.