Hi Gurus,

I know, I must be a dork for not knowing it. But how do you delete a pointer created with placement-new? I'm trying to get with the sample below and I keep thinking that there should be a placement version of delete that correctly calls the dtor.

Is my code wrong?
Is there a right version of delete?

Thanks. Sincerely, Chris.

Code:
#include <memory>
#include <iostream>

typedef unsigned int UINT8;

class Something
{
public:
  Something() { }
  ~Something()
  {
    std::cout << "Something's dtor." << std::endl;
  }
};

void DoSomething(void)
{
  // Get a local buffer.
  UINT8 buffer[sizeof(Something)];

  // Create ps in the local buffer.
  Something* ps = new((void*) buffer) Something();

  // Do something with ps.

  // Delete ps.
  ps->~Something();
}

int main(void)
{
  DoSomething();
}