The OpenD Programming Language

uninitializedArray

Returns a new array of type T allocated on the garbage collected heap without initializing its elements. This can be a useful optimization if every element will be immediately initialized. T may be a multidimensional array. In this case sizes may be specified for any number of dimensions from 0 to the number in T.

uninitializedArray is nothrow and weakly pure.

uninitializedArray is @system if the uninitialized element type has pointers.

  1. auto uninitializedArray(I sizes)
  2. auto uninitializedArray(I sizes)
    nothrow @trusted
    uninitializedArray
    (
    T
    I...
    )
    ()

Parameters

T

The type of the resulting 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

double[] arr = uninitializedArray!(double[])(100);
assert(arr.length == 100);

double[][] matrix = uninitializedArray!(double[][])(42, 31);
assert(matrix.length == 42);
assert(matrix[0].length == 31);

char*[] ptrs = uninitializedArray!(char*[])(100);
assert(ptrs.length == 100);

Meta