1 static struct Foo 2 { 3 ~this() pure nothrow @nogc { if (_ptr) ++*_ptr; } 4 int* _ptr; 5 } 6 int[3] refs = [0, 1, 2]; 7 Foo[3] src = [Foo(&refs[0]), Foo(&refs[1]), Foo(&refs[2])]; 8 Foo[5] dst = void; 9 10 auto tail = moveEmplaceAll(src[], dst[]); // move 3 value from src over dst 11 assert(tail.length == 2); // returns remaining uninitialized values 12 initializeAll(tail); 13 14 import std.algorithm.searching : all; 15 assert(src[].all!(e => e._ptr is null)); 16 assert(dst[0 .. 3].all!(e => e._ptr !is null));
Similar to moveAll but assumes all elements in tgt are uninitialized. Uses moveEmplace to move elements from src over elements from tgt.