diff options
Diffstat (limited to 'include/StringView.hpp')
-rw-r--r-- | include/StringView.hpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/include/StringView.hpp b/include/StringView.hpp index 4e9066b..9eea387 100644 --- a/include/StringView.hpp +++ b/include/StringView.hpp @@ -15,7 +15,7 @@ namespace dchat } - BasicStringView(const BasicStringView<CharType> &other) : data(other.data), size(other.size) + BasicStringView(const BasicStringView<CharType> &other) : data(other.data), size(other.size) { } @@ -30,13 +30,14 @@ namespace dchat } - BasicStringView<CharType> operator = (const BasicStringView<CharType> &other) + BasicStringView<CharType>& operator = (const BasicStringView<CharType> &other) { - BasicStringView<CharType> result(other.data, other.size); - return result; + data = other.data; + size = other.size; + return *this; } - BasicStringView( BasicStringView<CharType> &&other) + BasicStringView(BasicStringView<CharType> &&other) { data = other.data; size = other.size; @@ -45,10 +46,10 @@ namespace dchat other.size = 0; } - bool equals(const BasicStringView<CharType> &other) const + bool equals(const BasicStringView<CharType> &other) const { if(size != other.size) return false; - return memcmp(data, other.data, size) == 0; + return memcmp(data, other.data, size * sizeof(CharType)) == 0; } CharType operator [] (usize index) const |