Re: int[3][4]*

2012-09-08 Thread Artur Skawina
On 09/08/12 05:27, Timon Gehr wrote: On 09/08/2012 04:19 AM, bearophile wrote: Ellery Newcomer: alright what's the deal? This is one of the clean ways to do it: void main () { static struct Mat { int[3][4] m; alias m this; } Mat* fooz = new Mat

Re: int[3][4]*

2012-09-08 Thread bearophile
Timon Gehr: This may corrupt your heap. I usually don't put the alis this... I prefer this: void main(){ alias int[3][4] fooz; int[3][4]* i = (new fooz[1]).ptr; } This allocates past the size of the array, the information to append to the array of fooz. It's a very little

Re: int[3][4]*

2012-09-08 Thread Timon Gehr
On 09/08/2012 01:21 PM, bearophile wrote: Timon Gehr: This may corrupt your heap. I usually don't put the alis this... I prefer this: void main(){ alias int[3][4] fooz; int[3][4]* i = (new fooz[1]).ptr; } This allocates past the size of the array, the information to append

int[3][4]*

2012-09-07 Thread Ellery Newcomer
alright what's the deal? void main () { alias int[3][4] fooz; int[3][4]* i = new fooz; } wiz.d(6): Error: new can only create structs, dynamic arrays or class objects, not int[3LU][4LU]'s

Re: int[3][4]*

2012-09-07 Thread bearophile
Ellery Newcomer: alright what's the deal? This is one of the clean ways to do it: void main () { static struct Mat { int[3][4] m; alias m this; } Mat* fooz = new Mat; fooz[1][3] = 5; } Bye, bearophile

Re: int[3][4]*

2012-09-07 Thread Timon Gehr
On 09/08/2012 04:19 AM, bearophile wrote: Ellery Newcomer: alright what's the deal? This is one of the clean ways to do it: void main () { static struct Mat { int[3][4] m; alias m this; } Mat* fooz = new Mat; fooz[1][3] = 5; This may corrupt your heap