summaryrefslogtreecommitdiffhomepage
path: root/include/unicode/endian.h
blob: 38bc1b7f9992b4f0236e0e586d3c4ab0e3519f18 (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
#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