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

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -