arraydup

Makes a copy of the given array on newly allocated memory.

extern (D) pure nothrow
T[]
arraydup
(
T
)
(
const scope T[] s
)

Parameters

s T[]

array to copy

Return Value

Type: T[]

A copy of the input array.

Examples

auto s1 = [0, 1, 2];
auto s2 = s1.arraydup;
s2[0] = 4;
assert(s1 == [0, 1, 2]);
assert(s2 == [4, 1, 2]);
string sEmpty;
assert(sEmpty.arraydup is null);

Meta