BAN: ByteSpan can be sliced without specified size

This will give span with all remaining size after offset
This commit is contained in:
Bananymous 2023-10-25 21:40:11 +03:00
parent 8bb47aee02
commit fda4a4ad24
1 changed files with 4 additions and 1 deletions

View File

@ -87,9 +87,12 @@ namespace BAN
return *reinterpret_cast<S*>(m_data);
}
ByteSpanGeneral slice(size_type offset, size_type length)
ByteSpanGeneral slice(size_type offset, size_type length = size_type(-1))
{
ASSERT(m_data);
ASSERT(m_size >= offset);
if (length == size_type(-1))
length = m_size - offset;
ASSERT(m_size >= offset + length);
return ByteSpanGeneral(m_data + offset, length);
}