util/SpanCast: add ReferenceAsWritableBytes()

This commit is contained in:
Max Kellermann 2023-10-28 16:28:23 +02:00 committed by Max Kellermann
parent a073db1e52
commit 68b19ae087
1 changed files with 7 additions and 0 deletions

View File

@ -69,6 +69,13 @@ ReferenceAsBytes(const T &value) noexcept
return std::as_bytes(std::span<const T, 1>{&value, 1}); return std::as_bytes(std::span<const T, 1>{&value, 1});
} }
template<typename T>
constexpr auto
ReferenceAsWritableBytes(T &value) noexcept
{
return std::as_writable_bytes(std::span<T, 1>{&value, 1});
}
constexpr std::string_view constexpr std::string_view
ToStringView(std::span<const char> s) noexcept ToStringView(std::span<const char> s) noexcept
{ {