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:
parent
aacbee8ed8
commit
1069979ddf
2 changed files with 24 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue