From 53d1d12c12661c73fee491fecb0d141b94c9067e Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 13 Jan 2023 00:55:58 +0200 Subject: [PATCH] BAN: String add operator=(StringView) --- BAN/BAN/String.cpp | 8 ++++++-- BAN/include/BAN/String.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/BAN/BAN/String.cpp b/BAN/BAN/String.cpp index 609cf69d4..7c4908cfe 100644 --- a/BAN/BAN/String.cpp +++ b/BAN/BAN/String.cpp @@ -48,6 +48,12 @@ namespace BAN return *this; } + String& String::operator=(StringView other) + { + MUST(copy_impl(other)); + return *this; + } + ErrorOr String::PushBack(char ch) { TRY(EnsureCapasity(m_size + 2)); @@ -70,8 +76,6 @@ namespace BAN ErrorOr String::Insert(StringView other, size_type index) { - dprintln("insert '{}' to '{}' at index {}", other, *this, index); - ASSERT(index <= m_size); TRY(EnsureCapasity(m_size + other.Size() + 1)); memmove(m_data + index + other.Size(), m_data + index, m_size - index); diff --git a/BAN/include/BAN/String.h b/BAN/include/BAN/String.h index 3ec3d6cf2..c281845ad 100644 --- a/BAN/include/BAN/String.h +++ b/BAN/include/BAN/String.h @@ -24,6 +24,7 @@ namespace BAN String& operator=(const String&); String& operator=(String&&); + String& operator=(StringView); [[nodiscard]] ErrorOr PushBack(char); [[nodiscard]] ErrorOr Insert(char, size_type);