util/SpanCast: add ToStringView()

This commit is contained in:
Max Kellermann 2022-06-08 14:10:58 +02:00 committed by Max Kellermann
parent 3a0a0facdf
commit 64f2735e60

View File

@ -85,3 +85,15 @@ AsBytes(std::string_view sv) noexcept
{
return std::as_bytes(ToSpan(sv));
}
constexpr std::string_view
ToStringView(std::span<const char> s) noexcept
{
return {s.data(), s.size()};
}
constexpr std::string_view
ToStringView(std::span<const std::byte> s) noexcept
{
return ToStringView(FromBytesStrict<const char>(s));
}