struct to byte[]

Luís Marques luismarques+spam at gmail.com
Tue Dec 12 12:31:40 PST 2006


Hello,

Converting a structure to ubyte[] or similar is something that I have 
been doing frequently while converting C to D code.

Can we have a "cast(type[])" working for structures, please?

I suppose that type should include at least ubyte, byte and char, if not 
all the basic data types.

Is there a reason for this explicit cast not to work automatically? (I 
know that templates can alleviate this)

E.g.

struct Foo
{
     int a;
     float b;
}

converts to ubyte[8] via "cast(ubyte[])".


--
Luís



More information about the Digitalmars-d mailing list