diff options
author | Roland Reichwein <mail@reichwein.it> | 2022-01-01 20:25:34 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2022-01-01 20:25:34 +0100 |
commit | 52d4375b10d920a59f1309c272a2e525feb1c25d (patch) | |
tree | 9d5417a9d214f4b0ba68b75e8908e28da46dd5c8 /include/unicode/endian.h | |
parent | ae7b430afd1239947b8f8b2d9dc0ca72dbce91ac (diff) |
Separated out headers files; optimizations; type traits; better naming
Diffstat (limited to 'include/unicode/endian.h')
-rw-r--r-- | include/unicode/endian.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/unicode/endian.h b/include/unicode/endian.h new file mode 100644 index 0000000..38bc1b7 --- /dev/null +++ b/include/unicode/endian.h @@ -0,0 +1,26 @@ +#pragma once + +#if __cplusplus >= 202002L +#include <bit> +#endif + +namespace unicode::detail { + +#if __cplusplus >= 202002L + consteval +#else + constexpr uint16_t endian_value{0x0102}; + constexpr uint8_t endian_value_1st_byte{(const uint8_t&)endian_value}; + + constexpr +#endif + bool is_little_endian() + { +#if __cplusplus >= 202002L + return std::endian::native == std::endian::little; +#else + return endian_value_1st_byte == 0x02; +#endif + } + +} // namespace unicode::detail |