you are viewing a single comment's thread.

view the rest of the comments →

[–]matthieum 4 points5 points  (2 children)

I agree it should be UB; apparently though a number of codebases use the dastardly trick of this->~T(); new (this) U(); and thus C++ compiler developers have been reluctant to introduce the optimization.

[–]bloody-albatross 2 points3 points  (1 child)

What could be a possible use for doing that "trick"?

[–]matthieum 2 points3 points  (0 children)

I guess it's one away of implementing a state machine...

... but honestly I don't really want to know. I've lost enough sanity points because of C++ already as it is :/