The OpenD Programming Language

copyEmplace

Emplaces a copy of the specified source value into uninitialized memory, i.e., simulates T target = source copy-construction for cases where the target memory is already allocated and to be initialized with a copy.

@system
void
copyEmplace
(
S
T
)
(
ref S source
,
ref T target
)
if (
is(immutable S == immutable T)
)

Parameters

source S

value to be copied into target

target T

uninitialized value to be initialized with a copy of source

Examples

int source = 123;
int target = void;
copyEmplace(source, target);
assert(target == 123);
immutable int[1][1] source = [ [123] ];
immutable int[1][1] target = void;
copyEmplace(source, target);
assert(target[0][0] == 123);
struct S
{
    int x;
    void opAssign(const scope ref S rhs) @safe pure nothrow @nogc
    {
        assert(0);
    }
}

S source = S(42);
S target = void;
copyEmplace(source, target);
assert(target.x == 42);

Meta