staticArray returns by value, so expressions involving large arrays may be inefficient.
Parameters
a | The input array. |
Returns
A static array constructed from
a.T[n] staticArray(T, size_t n)(auto ref T[n] a)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]
staticArray returns by value, so expressions involving large arrays may be inefficient.
a | The input array. |
a.auto staticArray(size_t n, T)(scope T a) if (isInputRange!T)Constructs a static array from a range. When a.length is not known at compile time, the number of elements must be given as a template argument (e.g. myrange.staticArray!2). Size and type can be combined, if the source range elements are implicitly convertible to the requested element type (eg: 2.iota.staticArray!(long[2])).
When the range a is known at compile time, it can be given as a template argument to avoid having to specify the number of elements (e.g.: staticArray!(2.iota) or staticArray!(double, 2.iota)).
a | The input range. If there are less elements than the specified length of the static array, the rest of it is default-initialized. If there are more than specified, the first elements up to the specified length are used. |
rangeLength | Output for the number of elements used from a. Optional. |
auto staticArray(size_t n, T)(scope T a, out size_t rangeLength) if (isInputRange!T)ditto
auto staticArray(Un : U[n], U, size_t n, T)(scope T a) if (isInputRange!T && is(ElementType!T : U))ditto
auto staticArray(Un : U[n], U, size_t n, T)(scope T a, out size_t rangeLength) if (isInputRange!T && is(ElementType!T : U))ditto
auto staticArray(alias a)() if (isInputRange!(typeof(a)))ditto
auto staticArray(U, alias a)() if (isInputRange!(typeof(a)))ditto