moveEmplaceAll

Similar to moveAll but assumes all elements in tgt are uninitialized. Uses moveEmplace to move elements from src over elements from tgt.

@system
InputRange2
moveEmplaceAll
(
InputRange1
InputRange2
)
(
InputRange1 src
,
InputRange2 tgt
)
if (
isInputRange!InputRange1 &&
isInputRange!InputRange2
&&
is(typeof(moveEmplace(src.front, tgt.front)))
)

Examples

static struct Foo
{
    ~this() pure nothrow @nogc { if (_ptr) ++*_ptr; }
    int* _ptr;
}
int[3] refs = [0, 1, 2];
Foo[3] src = [Foo(&refs[0]), Foo(&refs[1]), Foo(&refs[2])];
Foo[5] dst = void;

auto tail = moveEmplaceAll(src[], dst[]); // move 3 value from src over dst
assert(tail.length == 2); // returns remaining uninitialized values
initializeAll(tail);

import std.algorithm.searching : all;
assert(src[].all!(e => e._ptr is null));
assert(dst[0 .. 3].all!(e => e._ptr !is null));

Meta