Safely cast a value of a type to another, if both have the same size.
Unlike bruteCast, the same location si not shared between the source and the target and no pointer is used. This function is inspired by http://www.forwardscattering.org/post/27
assert(bitCast!int(1.0f) == 0x3f800000); version(LittleEndian) assert(bitCast!(ubyte[2])(ushort(0x1234)) == [0x34, 0x12]); else assert(bitCast!(ubyte[2])(ushort(0x1234)) == [0x12, 0x34]);
See Implementation
Safely cast a value of a type to another, if both have the same size.
Unlike bruteCast, the same location si not shared between the source and the target and no pointer is used. This function is inspired by http://www.forwardscattering.org/post/27