c++ - How placement new can be done on stack -
c++ - How placement new can be done on stack -
consider next codes:
char mem[sizeof(char)]; void* p = mem; f = new(p) char; since memory variable mem should on stack so, why doesn't piece of memory collected automatically in end.
the memory collected automatically.
but destructor won't called automatically. when utilize placement new, should pair manual destructor call. char doesn't matter of course, since destructor trivial.
c++ new-operator placement
Comments
Post a Comment