move

Phobos move, but always by destructive copy when in debug mode.

Performs the same operations as core.lifetime.move, but when in debug mode the moved source is always set to its .init value, which is easier to check (e.g. null for pointers) when looking for referential integrity bugs.

  1. void move(T source, T target)
    void
    move
    (
    T
    )
    (
    ref T source
    ,
    ref T target
    )
  2. T move(T source)

Examples

int x = 1;
int* p = &x;
int* q = null;
move(p, q);
assert(q == &x);
debug assert(p == null); // only in debug mode!