18hi_warning_ignore_msvc(26490)
20namespace hi::inline v1 {
22using byteptr = std::byte *;
23using cbyteptr = std::byte
const *;
25class byte_char_traits {
27 using char_type = std::byte;
28 using int_type =
unsigned int;
33 static constexpr void assign(std::byte &r, std::byte
const &a)
noexcept
38 static constexpr bool eq(std::byte a, std::byte b)
noexcept
40 return static_cast<uint8_t
>(a) ==
static_cast<uint8_t
>(b);
43 static constexpr bool lt(std::byte a, std::byte b)
noexcept
45 return static_cast<uint8_t
>(a) <
static_cast<uint8_t
>(b);
48 static std::byte *assign(std::byte *p,
std::size_t count, char_type a)
noexcept
50 return static_cast<std::byte *
>(
std::memset(p,
static_cast<uint8_t
>(a), count));
53 static std::byte *
move(std::byte *dest, std::byte
const *src,
std::size_t count)
noexcept
55 return static_cast<std::byte *
>(
std::memmove(dest, src, count));
58 static std::byte *
copy(std::byte *dest, std::byte
const *src,
std::size_t count)
noexcept
60 return static_cast<std::byte *
>(
std::memcpy(dest, src, count));
63 static int compare(std::byte
const *a, std::byte
const *b,
std::size_t count)
noexcept
68 static std::size_t length(std::byte
const *s)
noexcept
70 return std::strlen(
reinterpret_cast<char const *
>(s));
73 static std::byte
const *
find(std::byte
const *s,
std::size_t count, std::byte
const &ch)
noexcept
75 return static_cast<std::byte
const *
>(
76 std::memchr(
reinterpret_cast<char const *
>(s),
static_cast<uint8_t
>(ch), count));
79 static constexpr std::byte to_char_type(
unsigned int c)
noexcept
81 return static_cast<std::byte
>(c);
84 static constexpr unsigned int to_int_type(std::byte c)
noexcept
86 return static_cast<unsigned int>(c);
89 static constexpr bool eq_int_type(
unsigned int c1,
unsigned int c2)
noexcept
94 static constexpr unsigned int eof() noexcept
99 static constexpr unsigned int not_eof(
unsigned int e)
noexcept
101 return eq_int_type(e, eof()) ? 0 : e;
106using bstring_view = std::basic_string_view<std::byte, byte_char_traits>;
108[[nodiscard]]
inline bstring to_bstring(std::string_view src)
noexcept
110 return bstring{
reinterpret_cast<std::byte
const *
>(src.data()), src.
size()};
113[[nodiscard]]
inline bstring to_bstring(std::integral
auto... args)
noexcept
115 return bstring{{
static_cast<std::byte
>(args)...}};
This file includes required definitions.