31struct bytes_view : std::basic_string_view<std::byte, detail::byte_traits> {
32 using base_type = std::basic_string_view<std::byte, detail::byte_traits>;
34 constexpr bytes_view()
noexcept =
default;
36 constexpr bytes_view(
const std::byte *data, std::size_t size) noexcept
37 : base_type(data, size) {}
39 constexpr bytes_view(
const void *data, std::size_t size) noexcept
40 : base_type(
static_cast<const std::byte *
>(data), size) {}
42 constexpr bytes_view(
const base_type &v)
noexcept
43 : base_type(v.data(), v.size()) {}
45 template<std::
size_t SIZE>
46 constexpr bytes_view(
const char (&v)[SIZE])
noexcept
47 : base_type(
reinterpret_cast<const std::byte *
>(v), SIZE) {}
49 template<std::
size_t SIZE>
50 constexpr bytes_view(
const std::array<std::byte, SIZE> &v)
noexcept
51 : base_type(v.data(), v.size()) {}
53 bytes_view(
const std::string &v)
noexcept
54 : base_type(
reinterpret_cast<const std::byte *
>(v.data()), v.size()) {}
56 bytes_view(
const std::string_view &v)
noexcept
57 : base_type(
reinterpret_cast<const std::byte *
>(v.data()), v.size()) {}
59 bytes_view(
const std::vector<std::byte> &v)
noexcept
60 : base_type(v.data(), v.size()) {}
62 explicit operator std::string()
const {
return {
reinterpret_cast<const char *
>(data()), size()}; }
64 explicit operator std::vector<std::byte>()
const {
return {begin(), end()}; }