On 11/07/2014 1:18 a.m., Sean Campbell wrote:
perhaps I'd better state what I'm doing. i have an array of 4 bytes and a want to convert them to a 32 bit int and convert the 32 bit int back into a 4 bytes again.
Small hack I use in Dakka: union RawConvTypes(T) { T value; ubyte[T.sizeof] bytes; ubyte[T.sizeof] opCast() { return bytes; } } auto iRCT = RawConvTypes!int(5); assert(iRCT.bytes == [5, 0, 0, 0]); Can be quite useful for evil conversions.