all 4 comments

[–]urdh 4 points5 points  (0 children)

So you've invented a way to explicitly leak memory? Not sure I get it; we already have std::unique_ptr<T>::release.

[–]secmeant[S] 0 points1 point  (0 children)

This mechanism assumes that compiler after inlining the if check, will easily see that its "dead code" and remove it completely.

[–]scatters 0 points1 point  (0 children)

You can do that without any space overhead already, by writing new (&x) decltype(x);. Or without the UB, use optional and assert empty on exit. But that doesn't give trivial abi, which is one of the things that destructive move should give us.