1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 17:07:47 +00:00

AK: Implement Span::starts_with()

Useful for checking for contents at the start of a span.
This commit is contained in:
Valtteri Koskivuori 2021-05-03 21:46:18 +03:00 committed by Linus Groh
parent aacbee8ed8
commit 1069979ddf
2 changed files with 24 additions and 0 deletions

View file

@ -176,6 +176,14 @@ public:
return false;
}
bool constexpr starts_with(Span<const T> other) const
{
if (size() < other.size())
return false;
return TypedTransfer<T>::compare(data(), other.data(), other.size());
}
ALWAYS_INLINE constexpr const T& at(size_t index) const
{
VERIFY(index < this->m_size);