I searched the forum but did not find something.

I want to do this:

int foo(T)(ref T s1, ref T s2)
{
    const byte[] s1b = (cast(const(byte)*)&s1)[0 .. T.sizeof];
    const byte[] s2b = (cast(const(byte)*)&s2)[0 .. T.sizeof];
}

Which is to create a byte array from the bytes of the value given, no matter
the type. The above works, but it's not @safe.

Thanks,
Stefanos

Reply via email to