casting and arrays..
Jarrett Billingsley
kb3ctd2 at yahoo.com
Sat Mar 10 16:10:11 PST 2007
"Chris Warwick" <sp at m.me.not> wrote in message
news:esvf5h$2317$1 at digitalmars.com...
> std.file.read(filename);
>
> returns type void[]
>
> And it it seems i can cast that to whatever type i like, int[], bool[],
> ect.. anyway it compiles... but.. when casting between array types like
> this are runtime checks made to make sure the block being cast has the
> correct granularity..
Yes.
> if the return was void[7] will i get an runtime error casting it to int?
Yes.
void main()
{
ubyte[] a = [cast(ubyte)1, 2, 3, 4, 5, 6, 7];
int[] x = cast(int[])a;
}
That cast will give an "array cast misalignment" at run-time.
More information about the Digitalmars-d-learn
mailing list