summaryrefslogtreecommitdiffhomepage
path: root/include/unicode/endian.h
blob: 1230f06cb23a312ca162e6b051f0c901adb304b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once

#if __cplusplus >= 202002L
#include <bit>
#endif
#include <cstdint>

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