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

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));

Meta

Suggestion Box / Bug Report