summaryrefslogtreecommitdiffhomepage
path: root/include/unicode/endian.h
blob: d933a2be4a7b930134481cfd0e7c52bfa6f66094 (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
28
29
30
31
32
33
34
35
//
// Reichwein.IT Unicode Library
//
// Endian handling functions
//
// In C++17, endian support is not yet available.
//

#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