BAN: Implement String::operator==(const String&)

This commit is contained in:
Bananymous 2023-12-24 13:36:46 +02:00
parent 9b8e6e6629
commit 0e714d5eb4
2 changed files with 11 additions and 0 deletions

View File

@ -134,6 +134,16 @@ namespace BAN
data()[m_size] = '\0';
}
bool String::operator==(const String& str) const
{
if (size() != str.size())
return false;
for (size_type i = 0; i < m_size; i++)
if (data()[i] != str.data()[i])
return false;
return true;
}
bool String::operator==(StringView str) const
{
if (size() != str.size())

View File

@ -55,6 +55,7 @@ namespace BAN
char operator[](size_type index) const { ASSERT(index < m_size); return data()[index]; }
char& operator[](size_type index) { ASSERT(index < m_size); return data()[index]; }
bool operator==(const String&) const;
bool operator==(StringView) const;
bool operator==(const char*) const;