diff --git a/src/util/SpanCast.hxx b/src/util/SpanCast.hxx index ea2a870bb..a1bccac63 100644 --- a/src/util/SpanCast.hxx +++ b/src/util/SpanCast.hxx @@ -29,6 +29,7 @@ #pragma once +#include #include #include #include @@ -52,6 +53,18 @@ FromBytesFloor(std::span> other) noexcept }; } +/** + * Like FromBytesFloor(), but assert that rounding is not necessary. + */ +template +constexpr std::span +FromBytesStrict(std::span> other) noexcept +{ + assert(other.size() % sizeof(T) == 0); + + return FromBytesFloor(other); +} + constexpr std::span ToSpan(std::string_view sv) noexcept {