How to pass in reference a fixed array in parameter
evilrat
evilrat666 at gmail.com
Wed Jun 5 12:38:10 UTC 2024
On Wednesday, 5 June 2024 at 11:27:32 UTC, Nick Treleaven wrote:
> On Wednesday, 5 June 2024 at 09:24:23 UTC, evilrat wrote:
>> for simple cases like this it might work, but 2d array is not
>> even contiguous,
>
> A 2D static array is contiguous:
> https://dlang.org/spec/arrays.html#rectangular-arrays
>
>> D static arrays, while using the same syntax, are implemented
>> as a fixed rectangular layout in a contiguous block of memory
Yeah ok, i might have messed up with columns last time, but it
works.
```d
int[5][5] test;
foreach(i; 0..5) {
foreach(j; 0..5) {
test[i][j] = i * 5 + j;
}
}
foreach(i; 0..25) {
assert(test[0].ptr[i] == i);
}
```
More information about the Digitalmars-d-learn
mailing list