diff --git a/BAN/include/BAN/ByteSpan.h b/BAN/include/BAN/ByteSpan.h index b920f6db..e86ba8f8 100644 --- a/BAN/include/BAN/ByteSpan.h +++ b/BAN/include/BAN/ByteSpan.h @@ -80,13 +80,30 @@ namespace BAN } template - const S& as() const + requires(is_const_v) + S& as() const { ASSERT(m_data); ASSERT(m_size >= sizeof(S)); return *reinterpret_cast(m_data); } + template + requires(!CONST && !is_const_v) + Span as_span() + { + ASSERT(m_data); + return Span(reinterpret_cast(m_data), m_size / sizeof(S)); + } + + template + requires(is_const_v) + Span as_span() const + { + ASSERT(m_data); + return Span(reinterpret_cast(m_data), m_size / sizeof(S)); + } + ByteSpanGeneral slice(size_type offset, size_type length = size_type(-1)) { ASSERT(m_data);