19#ifndef MTSTD_BYTE_ORDER_HPP
20#define MTSTD_BYTE_ORDER_HPP
37 constexpr auto machine = std::endian::native;
42 constexpr auto opposite = std::endian::native == std::endian::little ? std::endian::big : std::endian::little;
64 return bytes << 24 | ((bytes << 8) & 0xFF0000) | ((bytes >> 8) & 0xFF00) | ((bytes >> 24) & 0xFF);
81 static_assert(std::same_as<u16, T> || std::same_as<char16_t, T> || std::same_as<u32, T> ||
82 std::same_as<char32_t, T>);
83 if constexpr (std::is_same_v<u16, T>) {
86 else if constexpr (std::is_same_v<char16_t, T>) {
89 else if constexpr (std::is_same_v<u32, T>) {
constexpr char32_t flip_endian_ch32(const char32_t ch)
Flips the endianness of a char32.
constexpr char16_t flip_endian_ch16(const char16_t ch)
Flips the endianness of a char16.
constexpr u16 flip_endian_u16(const u16 bytes)
Flips the endianness of a u16.
constexpr auto opposite
endian that is opposite of machine (opposite of std::endian::native)
constexpr auto flip_endian(const T bytes)
Flips the endian of a u16, char16, u32, or char32.
constexpr u32 flip_endian_u32(const u32 bytes)
Flips the endianness of a u3.
constexpr auto machine
endian of machine (alias for std::endian::native)
uint16_t u16
Alias for 16-bit unsigned ints.
uint32_t u32
Alias for 32-bit unsigned ints.
Core library for C++ with Zig-related functionality.