StaticArray - multiple declarations
Struct StaticArray
A fixed-length array on type T with an index that runs from
first to last inclusive. The bounds are supplied at
compile-time.
struct StaticArray(T, long first, long last)
;
Fields
Name | Type | Description |
_payload
|
T[last-first+1] | |
Methods
Name | Description |
opApply
|
Indexing operators yield or modify the value at a specified index.
|
opIndex
|
Indexing operators yield or modify the value at a specified index.
|
opIndexAssign
|
Indexing operators yield or modify the value at a specified index.
|
toFile
|
|
toFile
|
|
Example
A fixed-length array on type T with an index that runs from
first to last inclusive. The bounds are supplied at
compile-time.
StaticArray!(int, -10, 10) arr;
assert(arr.length == 21);
assert(arr.sizeof == arr.length * int.sizeof);
foreach (ref e; arr)
e = 42;
assert(arr[-10] == 42);
assert(arr[0] == 42);
assert(arr[10] == 42);
import std.conv : to;
foreach (i, ref e; arr)
e = i.to!int; // i is of type size_t.
assert(arr[-10] == -10);
assert(arr[0] == 0);
assert(arr[5] == 5);
assert(arr[10] == 10);
arr[5] = 15;
assert(arr[5] == 15);
Struct StaticArray
struct StaticArray(T, E)
if (is(E == enum));
Fields
Name | Type | Description |
_payload
|
T[E.max-E.min+1] | |
Methods
Name | Description |
opApply
|
Indexing operators yield or modify the value at a specified index.
|
opIndex
|
Indexing operators yield or modify the value at a specified index.
|
opIndexAssign
|
Indexing operators yield or modify the value at a specified index.
|
toFile
|
|
toFile
|
|