How to do "cast(ubyte[4])some_uint" in D1?

Nick Sabalausky a at a.a
Thu Jun 2 02:35:40 PDT 2011


In D2, I can treat a uint as an array of ubytes by doing this:

uint num = /+...whatever...+/;
ubyte[] = cast(ubyte[4])num;

How do I do that in D1?

IIRC, D1 requires an explicit slice operator to convert from a static-array 
to a slice/dynamic-array, so I tried this:

ubyte[] = (cast(ubyte[4])num)[];

But I get the error:
Error: e2ir: cannot cast num of type uint to type ubyte[4u]




More information about the Digitalmars-d-learn mailing list