Cannot cast void* to arrays..?
simendsjo
simendsjo at gmail.com
Fri Feb 24 15:06:20 PST 2012
On Fri, 24 Feb 2012 21:36:21 +0100, Andrej Mitrovic
<andrej.mitrovich at gmail.com> wrote:
> On 2/24/12, simendsjo <simendsjo at gmail.com> wrote:
>> I don't get it. This gives me a dynamic array, not a static:
>> char[1] a;
>> auto b = cast(void*)a;
>> auto c = (cast(char*)b)[0..1];
>> c.length = 10; // auch!
>>
>
> You can do:
> char[1] c = (cast(char*)b)[0..1];
Thanks! I had to do an explicit cast(char[1]) (or actually char[1][1] in
my case.)
More information about the Digitalmars-d-learn
mailing list