10#if defined(_MSC_VER) && !defined(__clang__)
11 little = 0, big = 1, native = little
13 little = __ORDER_LITTLE_ENDIAN__, big = __ORDER_BIG_ENDIAN__, native = __BYTE_ORDER__
17 void swap(uint8_t& a, uint8_t& b) { uint8_t t = a; a = b; b = t; }
18 template <u
int32_t N>
void byte_swap(uint8_t* b);
19 template <>
void byte_swap<1>(uint8_t* b) { }
20 template <>
void byte_swap<2>(uint8_t* b) { swap(b[0], b[1]); }
21 template <>
void byte_swap<4>(uint8_t* b) { swap(b[0], b[3]); swap(b[1], b[2]); }
22 template <>
void byte_swap<8>(uint8_t* b) { swap(b[0], b[7]); swap(b[1], b[6]); swap(b[2], b[5]); swap(b[3], b[4]); }
24 template <
typename T,
bool no_swap = endian::big == endian::native>
28 static void exec(T& v) { byte_swap<sizeof(T)>(
reinterpret_cast<uint8_t*
>(&v)); }
void big_endian_to_native(T &v)
convert value of a numeric type T from big endian to native endian of host
endian
enum providing access to native endian of host system
this header is dependency free