37 short int word = 0x0001;
38 char *
byte = (
char *) &
word;
39 return (
byte[0] ? 1 : 0);
53 constexpr i32 sz =
sizeof(
a);
57 auto constexpr lambd = []() {
58 if constexpr (sz % 2 == 0) {
std::uint8_t u8
8 bit unsigned integer
std::int32_t i32
32 bit integer
namespace for basic c++ utilities
void endian_swap(T &a)
Swap the endianness of the input value.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
T get_endian_swap(T a)
Return a copy of the input value with the endianness swapped.
bool is_little_endian()
Check if the CPU is in little endian.
void xor_swap(T &a, T &b)
swap two values using xor Source : https://graphics.stanford.edu/~seander/bithacks....