XH*****@gmail.com wrote:
something like this:
T *p = new(Alloc&)T;
Alloc& cannot be a pointer. Perhaps you mean &Alloc?
delete(Alloc&) p;
is that will take problems!
now we could use Dealloc(Alloc&, void *p);
in the bs's tech Faq, i could not find the reason why not take the
placement delete to the language!
thinks;
a placement new doesn't really allocate memory. It simply calls the
constructor.
To destroy an object without deallocating the memory, simply call the
destructor:
void* rawptr = malloc(sizeof(T));
T* p = new(rawptr) T;
p->~T(); // destruction, but not deallocation
free(rawptr); // deallocation
Regards,
Ben