diff --git a/src/util/SpanCast.hxx b/src/util/SpanCast.hxx index d786f9d89..10d45062c 100644 --- a/src/util/SpanCast.hxx +++ b/src/util/SpanCast.hxx @@ -89,15 +89,21 @@ ToStringView(std::span s) noexcept return ToStringView(FromBytesStrict(s)); } -constexpr std::string_view -ToStringView(std::span s) noexcept -{ - return ToStringView(FromBytesStrict(s)); -} - template constexpr std::basic_string_view> ToStringView(std::span s) noexcept { return {s.data(), s.size()}; } + +/* this overload matches std::span (without "const") and is + written that way to avoid ambiguities when passing an object that + has cast operators for both std::span and + std::span */ +template +constexpr std::string_view +ToStringView(std::span s) noexcept + requires(std::is_same_v, std::byte>) +{ + return ToStringView(FromBytesStrict(s)); +}