On Friday, 22 January 2016 at 01:53:53 UTC, Chris Wright wrote:
On Thu, 21 Jan 2016 21:52:06 +0000, Dibyendu Majumdar wrote:
Hi
I have C code where the struct has a trailing array member:
struct matrix {
int rows;
int cols;
double data[1];
};
D has bounds checking, which makes this awkward. You would be
able to access the data using:
struct matrix {
int rows, cols;
double[] data() {
void* p = &this;
p += this.sizeof;
return (cast(double*)p)[0 .. rows * cols];
}
}
Right - I should use slices in other words.
Thanks