
On Sun, Aug 5, 2012 at 5:57 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
On Sun, 5 Aug 2012, John Maddock wrote:
Well, what happens then if you do something to a moved-from object other
than destructing it?
number a=2; number b=move(a); a=2; // or a=b; or a=b+1; or ...
It blows up your computer ;-)
IMO It's a constraint (and the intent of move semantics), that moved-from objects can only be destroyed: if you require that the moved-from object remain usable, then move-assign become identical to a regular assign, and move semantics are basically useless. Not just for this lib, but for the std lib as well.
That doesn't match my understanding. What I got from previous discussions is that you need to be able to assign to a moved-from object.
For instance, std::swap will only work for you if you implemented move assignment as a swap. vector::insert will move elements to the right (one move construction, the rest are move assignments) and then copy-assign a new value to the moved-from hole (at least that's how it is implemented in libcxx).
I believe Marc is correct. You must be able to destruct *and* assign-to a moved-from object. - Jeff