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