|
|
|
|
|
by quietbritishjim
559 days ago
|
|
It's a real semantic difference, not a pedantic detail: It means that there is a practical reason that the moved-from object could be non-empty. A few standard library types do guarantee that the moved-from object is empty (e.g., the smart pointer types). For some others (basically, all containers except string), it is not explicitly stated that this is the case but it is hard to imagine an implementation that doesn't (due to time complexity and iterator invalidation rules). Arguably, this represents a bigger risk than string'e behaviour, but it's still interesting. |
|
What's the semantic difference? Of course moving a class will involve some amount of copying. How could it be any other way? If you have something like struct { int a[1000]; }, how are you supposed to move the contents of the struct without copying anything? What, you take a pair of really tiny scissors and cut a teeny tiny piece of the RAM, then glue the capacitors somewhere else?