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,
x
can be destroyed for sure. Can I assumex
is trivially destructible after move?- can
x
be assigned or move assigned to a new object ( I guess yes, as I have seen manyswap
uses 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_move
which works with (partially) overlapped source & destination range, likestd::copy
and 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