Hi :)

I made this function to inverse the bytes in intger or T (possible) type...

int reverseBytes(T)(T val)
{
        int retVal = 0;
        static if(is(T == string))
                retVal = to!int(val);

        return (retVal & 0x000000FF) << 24 |
                   (retVal & 0x0000FF00) << 8 |
                   (retVal & 0x00FF0000) >> 8 |
                   (retVal & 0xFF000000) >> 24;
}

//...
writefln("%x", reverseBytes(x"00402030"));
//...

When I execute this program, I got this exception:
std.conv.ConvException@C:\D\dmd2\src\phobos\std\conv.d(1968): Unexpected '@' when converting from type string to type int

Reply via email to