If an object is actually moved to another location, what are the operations supported on the original object?
To elaborate it, I have a type T with available move constructor. With the following statements
T x{constructor-args};
T y{std::move(x)};
what all can be done with the object x (provided that the object actually moves from x to y using available move constructor of T)?
Specifically,
xcan be destroyed for sure. Can I assumexis trivially destructible after move?- can
xbe assigned or move assigned to a new object ( I guess yes, as I have seen manyswapuses this)? can I construct a new object object in place of
x? If by any chance this is allowed, then is it possible to have auninitialized_movewhich works with (partially) overlapped source & destination range, likestd::copyand unlikestd::uninitialized_copy?T z{some-args}; x = z; //or x = std::move(z); T u{some-args}; new(&x) T{std::move(u)}; // or new(&x) T{u}; etc