util/SpanCast: merge two ToStringView() using std::remove_const_t

This commit is contained in:
Max Kellermann 2024-04-08 21:01:54 +02:00 committed by Max Kellermann
parent a09e33bf8e
commit e131f22642

View File

@ -9,6 +9,7 @@
#include <cstddef> #include <cstddef>
#include <span> #include <span>
#include <string_view> #include <string_view>
#include <type_traits>
/** /**
* Cast a std::span<std::byte> to a std::span<T>, rounding down to the * Cast a std::span<std::byte> to a std::span<T>, rounding down to the
@ -95,14 +96,7 @@ ToStringView(std::span<std::byte> s) noexcept
} }
template<typename T> template<typename T>
constexpr std::basic_string_view<T> constexpr std::basic_string_view<std::remove_const_t<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 ToStringView(std::span<T> s) noexcept
{ {
return {s.data(), s.size()}; return {s.data(), s.size()};