#include <memory>
int main()
{
int * pInt = new int();
*pInt = 1;
std::destroy_at(pInt); // Destructor called, but
// memory is still allocated.
*pInt = 2;
delete pInt; // Destructor called, and memory is deallocated.
// *pInt = 3; // Exception Thrown (in Debug Mode)
return 0;
}
Reference: http://en.cppreference.com/w/cpp/memory/destroy_at
No comments:
Post a Comment