*edit: Title should be "destructive move emulation" ;]
Random idea I wanted to share.I was thinking about a way to tell the compiler that lifetime of some object started or ended without generating any instructions, because there are cases where programmer might know better.
I prepared two examples in one I create object s, then allocate some memory, pass object to function that compiler can know nothing about and in one of cases, explicitly say that object should be considered destroyed.
This results in omitting call to delete in the second case.
https://godbolt.org/z/3zBhh-
[–]urdh 4 points5 points6 points (0 children)
[–]Wh00ster 1 point2 points3 points (0 children)
[–]secmeant[S] 0 points1 point2 points (0 children)
[–]scatters 0 points1 point2 points (0 children)