a struct as an multidimensional array index
Ali Çehreli
acehreli at yahoo.com
Sat Jun 11 15:01:05 UTC 2022
On 6/11/22 00:09, z wrote:
> I rechecked and it should be `X Y Z` for static array, but `Z Y X` for
> indexing/dynamic array creating with `new`
How so? I wrote the following program:
import std.stdio;
void main() {
enum X = 2;
enum Y = 3;
enum Z = 4;
int[X][Y][Z] s;
int[X][Y][] d = new int[X][Y][Z];
pragma(msg, typeof(s));
pragma(msg, typeof(d));
}
It outputs the following for the static and the dynamic arrays:
int[2][3][4]
int[2][3][]
Consistent elements, except the static array has a compile-time known
length.
Ali
More information about the Digitalmars-d-learn
mailing list