implicite deref on array element access? (indexing)
Jesse Phillips
jessekphillips+D at gmail.com
Fri Feb 25 07:34:51 PST 2011
spir Wrote:
> Hello,
>
> I thought it worked, just like implicite deref on (struct, class) member
> access. But I cannot have it work:
>
> auto a = [1,2,3];
> auto pa = &a;
> writeln((*pa)[2]); // ok
> writeln(pa[2]); // segfault
You aren't making a pointer to the data, only the array. I probably would have made the same mistake, but I think you want to use:
auto pa = a.ptr;
Don't know if there is a ptr property for array.
More information about the Digitalmars-d-learn
mailing list