BAN: Implement StringView::starts_with()

This commit is contained in:
Bananymous 2024-06-25 09:40:37 +03:00
parent 61aa1ea11f
commit b1869bced4
1 changed files with 15 additions and 0 deletions

View File

@ -165,6 +165,21 @@ namespace BAN
return {}; return {};
} }
constexpr bool starts_with(BAN::StringView target) const
{
if (target.size() > m_size)
return false;
for (size_type i = 0; i < m_size - target.size(); i++)
{
bool valid = true;
for (size_type j = 0; j < target.size() && valid; j++)
valid = (m_data[i + j] == target[j]);
if (valid)
return true;
}
return false;
}
constexpr bool contains(char ch) const constexpr bool contains(char ch) const
{ {
for (size_type i = 0; i < m_size; i++) for (size_type i = 0; i < m_size; i++)