On Saturday, 16 January 2016 at 14:46:47 UTC, Yazan D wrote:
You can also use a union:union Foo { int i; ubyte[4] b; } // write to int part Foo f = Foo(a); // then read from ubyte part writeln(foo.b);ps. I am not sure of the aliasing rules in D for unions. In C, this is allowed, but in C++, this is undefined behaviour AFAIK.
I sure hope it's not undefined behaviour in D, seeing as this technique is used several places in the standard library.