10#ifndef M5_UTILITY_STL_ENDIANESS_HPP
11#define M5_UTILITY_STL_ENDIANESS_HPP
13#if __cplusplus >= 202002L
16#elif __has_include(<endian.h>)
19#elif __has_include(<machine/endian.h>)
21#include <machine/endian.h>
31#if __cplusplus >= 202002L || DOXYGEN_PROCESS
33using endian = std::endian;
36#elif __has_include(<endian.h>) || __has_include(<machine/endian.h>)
39#if defined(__BYTE_ORDER)
43#elif defined(_BYTE_ORDER)
47#elif defined(BYTE_ORDER)
61constexpr uint32_t val32 = 0x11223344;
62constexpr uint8_t ref8 =
static_cast<const uint8_t&
>(val32);
64enum class endian {
little = 0x44,
big = 0x11, native = ref8 };
75constexpr bool little = m5::stl::endian::native == m5::stl::endian::little;
76constexpr bool big = m5::stl::endian::native == m5::stl::endian::big;
80static_assert(
little ||
big ||
other,
"Unable to determine endianness");
81static_assert(((int)little + (
int)
big + (int)other) == 1,
"Endian matches more than one");
constexpr bool little
true if little endian.
Definition endianness.hpp:75
constexpr bool other
true if other endian.
Definition endianness.hpp:77
constexpr bool big
true if big endian.
Definition endianness.hpp:76
Top level namespace of M5.
Definition bit_segment.hpp:17
STL compatibility functions and classes.