The OpenD Programming Language

staticArray

Constructs a static array from a dynamic array whose length is known at compile-time. The element type can be inferred or specified explicitly:

* [1, 2].staticArray returns int[2] * [1, 2].staticArray!float returns float[2]

Note: staticArray returns by value, so expressions involving large arrays may be inefficient.

Parameters

a T[n]

The input array.

Return Value

Type: T[n]

A static array constructed from a.

Examples

static array from array literal

auto a = [0, 1].staticArray;
static assert(is(typeof(a) == int[2]));
assert(a == [0, 1]);

static array from array with implicit casting of elements

auto b = [0, 1].staticArray!long;
static assert(is(typeof(b) == long[2]));
assert(b == [0, 1]);

Meta