static struct S { int member = 5; this(this) @nogc nothrow pure @safe { assert(false); } } S source, target = void; move(source, target); assert(target.member == 5); assert(move(target).member == 5); int x1 = 5, x2; move(x1, x2); assert(x2 == 5); assert(move(x2) == 5);
$(D_PSYMBOL moveEmplace).
Moves source into target assuming that target isn't initialized.
Moving the source copies it into the target and places the source into a valid but unspecified state, which means that after moving source can be destroyed or assigned a new value, but accessing it yields an unspecified value. target is destroyed before the new value is assigned. If target isn't initialized and therefore shouldn't be destroyed, $(D_PSYMBOL moveEmplace) can be used.
If target isn't specified, $(D_PSYMBOL move) returns the source as rvalue without calling its copy constructor or destructor.
source and target are the same object, $(D_PSYMBOL move) does nothing.