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
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
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
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
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
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