On Monday, May 2, 2016 at 9:49:24 AM UTC+10, Jim Blandy wrote: > No, we don't know that [moved-from strings become empty]. > The contract of a move in C++ is simply that the > source object is safe to destruct, but otherwise in an undefined state*. You > must not make any assumptions about its value. * (To be fair, in that context I think you were only arguing there that we can't assume anything about the value, but didn't explicitly rule out a reassignment.)
Sorry to revive this old thread, but I've just noticed that our MFBT Swap() is written in terms of Move()'s: > template<typename T> > inline void > Swap(T& aX, T& aY) > { > T tmp(Move(aX)); > aX = Move(aY); > aY = Move(tmp); > } This assumes that a moved-from object can safely be assigned to -- Which used to seem reasonable to me, but I got confused after our discussions here! Clang's std::swap does the same! (With extra checks that the type is move constructible&assignable.) So can we assume that any moved-from object should be left in a state that is safe to destruct AND safe to be assigned to? But no assumption can be made about the actual contained value, i.e.: It could be the same, it could be empty, or it could be in some unsafe-to-use state until destroyed or overwritten. _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform