Re: Why does multidimensional arrays not allocate properly?

2017-01-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 22 January 2017 at 08:18:35 UTC, Jot wrote: On Sunday, 22 January 2017 at 08:07:26 UTC, rikki cattermole wrote: On 22/01/2017 9:05 PM, Jot wrote: auto x = new int[][](n,m); But one cannot freely assign anywhere in x: x[3,6] = 4 crashes. I, can, of course, convert everything to a

Re: Why does multidimensional arrays not allocate properly?

2017-01-22 Thread albert-j via Digitalmars-d-learn
In anycase, what is the correct notation for indexing? x = new int[][](width, height) and x[height][width] or x[width][height]? It's x[width][height], but because indexing is 0-based, largest valid indexes are x[width-1][height-1].

Re: Why does multidimensional arrays not allocate properly?

2017-01-22 Thread Jot via Digitalmars-d-learn
On Sunday, 22 January 2017 at 08:07:26 UTC, rikki cattermole wrote: On 22/01/2017 9:05 PM, Jot wrote: auto x = new int[][](n,m); But one cannot freely assign anywhere in x: x[3,6] = 4 crashes. I, can, of course, convert everything to a linear matrix and index by i+w*j, but what's the point

Re: Why does multidimensional arrays not allocate properly?

2017-01-22 Thread rikki cattermole via Digitalmars-d-learn
On 22/01/2017 9:05 PM, Jot wrote: auto x = new int[][](n,m); But one cannot freely assign anywhere in x: x[3,6] = 4 crashes. I, can, of course, convert everything to a linear matrix and index by i+w*j, but what's the point of having multidimensional matrices in D if they don't allocate them

Why does multidimensional arrays not allocate properly?

2017-01-22 Thread Jot via Digitalmars-d-learn
auto x = new int[][](n,m); But one cannot freely assign anywhere in x: x[3,6] = 4 crashes. I, can, of course, convert everything to a linear matrix and index by i+w*j, but what's the point of having multidimensional matrices in D if they don't allocate them fully?