On Sun, 03 Jan 2010 06:53:53 -0500, Trass3r <[email protected]> wrote:

Am 03.01.2010, 12:33 Uhr, schrieb bearophile <[email protected]>:


// alternative 1:
enum RGBA[] data1 = [{0x00, 0x10, 0x20, 0x30}, {0x40, 0x50, 0x60, 0x70}];
// alternative 2:
enum RGBA[] data2 = [RGBA(0x00, 0x10, 0x20, 0x30), RGBA(0x40, 0x50, 0x60, 0x70)];



Alternative 1: I heard struct literals could be removed.
Alternative 2:
1) it's cumbersome, especially if you got a huge array
2) if you somehow fundamentally change the struct for whatever reason, you probably have to reassign everything.

I currently use the old casting hack:
auto PALETTE = (cast(RGBA*) cast(ubyte[]) [0xFF,...]) [0 .. 256];

You should be able to do this I would think:

auto PALETTE = cast(RGBA[])(cast(ubyte[])[0xFF,..]));

but it doesn't work. I think it probably should. Why would I cast each element to byte only to then cast to RGBA. I think the parentheses should make it clear how I want the cast to proceed. I agree there should be a way to invoke the "bitwise" cast in one line besides the hackish way you are forced to do it.

-Steve

Reply via email to