The OpenD Programming Language

minimallyInitializedArray

Returns a new array of type T allocated on the garbage collected heap.

Partial initialization is done for types with indirections, for preservation of memory safety. Note that elements will only be initialized to 0, but not necessarily the element type's .init.

minimallyInitializedArray is nothrow and weakly pure.

nothrow @trusted
minimallyInitializedArray
(
T
I...
)
()

Parameters

T

The type of the array elements

sizes I

The length dimension(s) of the resulting array

Return Value

Type: auto

An array of T with I.length dimensions.

Examples

import std.algorithm.comparison : equal;
import std.range : repeat;

auto arr = minimallyInitializedArray!(int[])(42);
assert(arr.length == 42);

// Elements aren't necessarily initialized to 0, so don't do this:
// assert(arr.equal(0.repeat(42)));
// If that is needed, initialize the array normally instead:
auto arr2 = new int[42];
assert(arr2.equal(0.repeat(42)));

Meta