copyBackward

Copies starting from the end of source into the end of target.

$(D_PSYMBOL copyBackward) copies the elements in reverse order, but the order of elements in the target is exactly the same as in the source.

source and target shall not overlap so that target points ahead of source.

target shall have enough space for source.length elements.

@nogc nothrow pure @trusted
void
copyBackward
(
const void[] source
,
void[] target
)

Parameters

source void[]

Memory to copy from.

target void[]

Destination memory.

Examples

t
{
    ubyte[6] mem = [ 'a', 'a', 'b', 'b', 'c', 'c' ];
    ubyte[6] expected = [ 'a', 'a', 'a', 'a', 'b', 'b' ];

    copyBackward(mem[0 .. 4], mem[2 .. $]);
    assert(equal(expected, mem)

See Also

$(D_PSYMBOL copy).

Precondition: source.length <= target.length.

Meta