to! converting 1D to 2D array

ed growlercab at gmail.com
Wed Mar 12 20:32:50 PDT 2014


On Wednesday, 12 March 2014 at 07:43:46 UTC, bearophile wrote:
> monarch_dodra:
>
>>    int[] a = [0, 1, 2, 3];
>>    int[2][1][2][1] b;
>>    *cast(int[4]*)&b = a;
>>    assert(b == [[[[0, 1]], [[2, 3]]]]);
>
> Those pointers are not needed:
>
> cast(int[4])b = a;
>
> Bye,
> bearoophile

Thanks for this, the casts work perfectly albeit a little ugly :D

Cheers,
ed


More information about the Digitalmars-d-learn mailing list