… | |
… | |
45 | |
45 | |
46 | namespace byteorder { |
46 | namespace byteorder { |
47 | static unsigned char e () |
47 | static unsigned char e () |
48 | { |
48 | { |
49 | const uint32_t u = 0x11223344; |
49 | const uint32_t u = 0x11223344; |
50 | return *(unsigned char *)u; |
50 | return *(unsigned char *)&u; |
51 | } |
51 | } |
52 | |
52 | |
53 | static bool big_endian () { return e () == 0x11; }; |
53 | static bool big_endian () { return e () == 0x11; }; |
54 | static bool network () { return big_endian (); }; |
54 | static bool network () { return big_endian (); }; |
55 | static bool little_endian () { return e () == 0x44; }; |
55 | static bool little_endian () { return e () == 0x44; }; |