R
REH
I've been trying to better understand the subtle rules for object
lifetime. The standard says that pointers to the memory of a
dynamically allocated object may be used in limited ways after the
object's destructor has executed (but the memory not deallocated).
Specifically, the pointer must be a void*. Does that mean, the
following is well defined?
#include <new>
class T {};
int main()
{
T* p = new T();
p->~T();
operator delete(static_cast<void*>(p));
return 0;
}
lifetime. The standard says that pointers to the memory of a
dynamically allocated object may be used in limited ways after the
object's destructor has executed (but the memory not deallocated).
Specifically, the pointer must be a void*. Does that mean, the
following is well defined?
#include <new>
class T {};
int main()
{
T* p = new T();
p->~T();
operator delete(static_cast<void*>(p));
return 0;
}