util/SpanCast: add ToStringView() template

This commit is contained in:
Max Kellermann 2022-11-15 00:36:24 +01:00
parent 1a6ec716ef
commit 7c4fca0ae1

View File

@ -96,3 +96,17 @@ ToStringView(std::span<const std::byte> s) noexcept
{
return ToStringView(FromBytesStrict<const char>(s));
}
template<typename T>
constexpr std::basic_string_view<T>
ToStringView(std::span<const T> s) noexcept
{
return {s.data(), s.size()};
}
template<typename T>
constexpr std::basic_string_view<T>
ToStringView(std::span<T> s) noexcept
{
return {s.data(), s.size()};
}