| 19 | } |
| 20 | |
| 21 | constexpr auto ByteSwap(std::integral auto value) |
| 22 | { |
| 23 | if constexpr((std::endian::native == std::endian::big) || |
| 24 | (sizeof(value) == 1)) { // #B chars don't need swapping |
| 25 | return value; |
| 26 | } else { |
| 27 | return ReverseBytes(value); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | static_assert(ByteSwap(uint64_t(0x123456789ABCDEF0)) == 0xF0DEBC9A78563412); |
| 32 | static_assert(ByteSwap(uint32_t(0x12345678)) == 0x78563412); |