char * buf = new char[sizeof(T)]; new (buf) T; T * t = (T *)buf; //code... //here I should destruct *t but as it is argument of template and can be //instantiated vi
Call the destructor
T * t = (T *)buf; t->~T();
then free memory with delete[] buf. Calling destructors explicitly is exactly how it is done for objects created with placement new.
delete[] buf
new