Re:Move, simply
by AnimalMuppet on Monday February 17, 2020 @03:53PM
(#22350640)
You made the moved-to pointer point to the moved-from allocated heap data. Now nothing points to the heap data that was initially allocated by the moved-to object. So if you don't delete[] the moved-to data pointer, then you leaked 32 bytes of heap.
Re:Move, simply
by gpu_explorer on Monday February 17, 2020 @04:00PM
(#22350709)
What happens when the program exits?
Re:Move, simply
by AnimalMuppet on Monday February 17, 2020 @04:03PM
(#22350727)
Then it doesn't matter. It matters if you run out of heap before the program exits, though.
But maybe with int data[32] as a data member this is harder to reason about.
This is a way to illustrate move semantics and confusion behind what happens to the 'moved from' object.