19 #if __has_include(<endian.h>)
21 #elif __has_include(<sys/endian.h>)
22 # include <sys/endian.h>
27 namespace seqan3::detail
41 template <std::
integral type>
42 constexpr type to_little_endian(type
const in) noexcept
44 if constexpr (std::endian::native == std::endian::little)
48 else if constexpr (std::endian::native == std::endian::big)
50 static_assert(
sizeof(type) <= 8,
51 "Can only convert the byte encoding for integral numbers with a size of up to 8 bytes.");
52 static_assert(std::has_single_bit(
sizeof(type)),
53 "Can only convert the byte encoding for integral numbers whose byte size is a power of two.");
55 if constexpr (
sizeof(type) == 2)
57 else if constexpr (sizeof(type) == 4)
59 else if constexpr (sizeof(type) == 8)
66 static_assert(std::endian::native == std::endian::little || std::endian::native == std::endian::big,
67 "Expected a little-endian or big-endian platform.");
The <bit> header from C++20's standard library.
The <concepts> header from C++20's standard library.