template type deduction of static 2d arrays

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 24 17:00:45 PDT 2014


On Fri, 24 Oct 2014 23:46:27 +0000
uri via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com> wrote:

> On a related note, does the D spec guarantee the following will 
> be rectangular in memory?
> 
> auto a = [ [1,2],[3,4] ];
ah, no, it's not. this is array of arrays, i.e. 'int[][]'. only static
arrays are guaranteed to be placed as one block of data. this will:

  int[2][2] a = [ [1,2],[3,4] ];

we have a nice PR from Kenji that allows the following declarations:

  int[$][$] a = [ [1,2],[3,4] ];

but alas, it's not in the mainline yet.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141025/cee1d4aa/attachment.sig>


More information about the Digitalmars-d-learn mailing list