Some array casts

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 21 10:08:43 PST 2015


> The sizeof values aren't relevant for D array casts. What 
> matters are the array "contents".

See:

void main() {
     int[5] m = cast(int[5])[1, 2, 3, 4, 5];
     assert(m == [1, 2, 3, 4, 5]);
     pragma(msg, m.sizeof); // 20u
     pragma(msg, [1, 2, 3, 4, 5].sizeof); // 8u
}


Bye,
bearophile


More information about the Digitalmars-d-learn mailing list