News for hackers. Stuff that matters.
Re:C-for-all: Extending C with modern safety and productivit... by madmax96 on Wednesday December 04, 2019 @06:38AM (#21701339)
Why is cloning rather than moving the wrong default?
Re:C-for-all: Extending C with modern safety and productivit... by gmueckl on Wednesday December 04, 2019 @06:59AM (#21701442)
It isn't. Cloning is what actually happens under the hood, if a and a2 are in different memory locations. Making a inaccessible after the assignment is merely a convention. With a struct that only has data members, there are no further consequences.

If the struct contains a pointer, you need a kind of additional contract that says how the memory that is pointed to is going to be managed, particularly when it is going to be freed and by whom. And that is where move semantics establish a constricting convention that is intended to make that unambiguous.