digitalmars.D.learn - multidimensional dynamic arrays
- Trass3r (4/4) Nov 15 2009 What's the short way to create a multidimensional dynamic array? I
- Ellery Newcomer (3/8) Nov 15 2009 auto array = new ubyte[][](width*height, numSprites);
- Trass3r (6/10) Nov 16 2009 Ah yeah, thanks, that was it.
- Steven Schveighoffer (4/9) Nov 16 2009 Especially now that static arrays are legitimate value types, new
- Trass3r (5/9) Nov 16 2009 Ah ok.
- Ellery Newcomer (6/15) Nov 16 2009 I think it has something to do with uniformity inside templates or
What's the short way to create a multidimensional dynamic array? I always forget how to do such stuff due to its strange syntax. auto array = new ubyte[width*height][numSprites]; doesn't work cause width*height is no "Integer constant expression"
Nov 15 2009
Trass3r wrote:What's the short way to create a multidimensional dynamic array? I always forget how to do such stuff due to its strange syntax. auto array = new ubyte[width*height][numSprites]; doesn't work cause width*height is no "Integer constant expression"auto array = new ubyte[][](width*height, numSprites); params might be backwards..
Nov 15 2009
Ellery Newcomer schrieb:auto array = new ubyte[][](width*height, numSprites); params might be backwards..Ah yeah, thanks, that was it. Don't get the reason for that syntax. Anyway it should really be described in the language docs. I'd expect it to be at http://www.digitalmars.com/d/2.0/arrays.html but "Rectangular Arrays" only explains how to declare them.
Nov 16 2009
On Mon, 16 Nov 2009 08:42:28 -0500, Trass3r <mrmocool gmx.de> wrote:Ellery Newcomer schrieb:Especially now that static arrays are legitimate value types, new ubyte[1][2] looks to the compiler like a dynamic array of 1 ubyte[1]'s. -Steveauto array = new ubyte[][](width*height, numSprites); params might be backwards..Ah yeah, thanks, that was it. Don't get the reason for that syntax.
Nov 16 2009
Steven Schveighoffer schrieb:Especially now that static arrays are legitimate value types, new ubyte[1][2] looks to the compiler like a dynamic array of 1 ubyte[1]'s.Ah ok. Maybe it's a good idea to alter the error message when the compiler detects a non-constant expression? Like if you meant to create a dynamic array use the []() syntax..
Nov 16 2009
Trass3r wrote:Ellery Newcomer schrieb:I think it has something to do with uniformity inside templates or something. alias ubyte[][] Foo; Foo foo = new Foo(1,2); still not sure about params.. I should look this up..auto array = new ubyte[][](width*height, numSprites); params might be backwards..Ah yeah, thanks, that was it. Don't get the reason for that syntax.
Nov 16 2009