xxxxxxxxxx
import std;
/**
* Safely casts one type of an array to another.
*/
T[] reinterpretCast(T, U)(ref U[] input) {
T[] _reinterpretCast() {
return cast(T[])(cast(void[])input);
}
if ((U.sizeof * input.length) % T.sizeof == 0){
return _reinterpretCast();
} else {
throw new Exception("Cannot cast safely!");
}
}
void main()
{
char*[1] a = [new char('\xCC')]; //[3, 4, 5];
auto slice = a[];
auto b = reinterpretCast!(int*)(slice);
writefln("%08X", *b[0]);
}