BAN: overloaded operator== for more types
This commit is contained in:
@@ -134,6 +134,20 @@ namespace BAN
|
||||
return memcmp(m_data, other.m_data, m_size) == 0;
|
||||
}
|
||||
|
||||
bool String::operator==(StringView other) const
|
||||
{
|
||||
if (m_size != other.Size())
|
||||
return false;
|
||||
return memcmp(m_data, other.Data(), m_size) == 0;
|
||||
}
|
||||
|
||||
bool String::operator==(const char* other) const
|
||||
{
|
||||
if (m_size != strlen(other))
|
||||
return false;
|
||||
return memcmp(m_data, other, m_size) == 0;
|
||||
}
|
||||
|
||||
ErrorOr<void> String::Resize(size_type size, char ch)
|
||||
{
|
||||
if (size < m_size)
|
||||
|
||||
@@ -29,13 +29,27 @@ namespace BAN
|
||||
return m_data[index];
|
||||
}
|
||||
|
||||
bool StringView::operator==(const StringView& other) const
|
||||
bool StringView::operator==(const String& other) const
|
||||
{
|
||||
if (m_size != other.Size())
|
||||
return false;
|
||||
return memcmp(m_data, other.Data(), m_size) == 0;
|
||||
}
|
||||
|
||||
bool StringView::operator==(StringView other) const
|
||||
{
|
||||
if (m_size != other.m_size)
|
||||
return false;
|
||||
return memcmp(m_data, other.m_data, m_size) == 0;
|
||||
}
|
||||
|
||||
bool StringView::operator==(const char* other) const
|
||||
{
|
||||
if (m_size != strlen(other))
|
||||
return false;
|
||||
return memcmp(m_data, other, m_size) == 0;
|
||||
}
|
||||
|
||||
StringView StringView::Substring(size_type index, size_type len) const
|
||||
{
|
||||
assert(index <= m_size);
|
||||
|
||||
Reference in New Issue
Block a user