Well, I know that sounds pure evil. I read this SO post and came across a technique for restoring a stack object. Main idea:
{
T obj(...);
obj.~T();
new (&obj) T(...);
}
... so that we can use the same piece of memory as many times as we like. Is this code legal by standard? This is crazy, how is this behavior undefined?
source
share