refactor: Return std::span from MakeByteSpan

In theory this commit should only touch the span.h header, because
std::span can implicilty convert into Span in most places, if needed.

However, at least when using the clang compiler, there are some
false-positive lifetimebound warnings and some implicit conversions can
not be resolved.

Thus, this refactoring commit also changed the affected places to
replace Span with std::span.
This commit is contained in:
MarcoFalke
2024-12-17 19:55:45 +01:00
parent aa68ed27b8
commit fa720b94be
8 changed files with 14 additions and 14 deletions

View File

@@ -266,14 +266,14 @@ Span<std::byte> AsWritableBytes(Span<T> s) noexcept
}
template <typename V>
Span<const std::byte> MakeByteSpan(V&& v) noexcept
auto MakeByteSpan(const V& v) noexcept
{
return AsBytes(Span{std::forward<V>(v)});
return std::as_bytes(std::span{v});
}
template <typename V>
Span<std::byte> MakeWritableByteSpan(V&& v) noexcept
auto MakeWritableByteSpan(V&& v) noexcept
{
return AsWritableBytes(Span{std::forward<V>(v)});
return std::as_writable_bytes(std::span{std::forward<V>(v)});
}
// Helper functions to safely cast basic byte pointers to unsigned char pointers.