This commit is contained in:
parent
4cac49038c
commit
0f678f845c
@ -17,6 +17,9 @@ class String
|
||||
String(String&&);
|
||||
String(const String&) = delete;
|
||||
|
||||
String& operator=(String&&);
|
||||
String& operator=(const String&) = delete;
|
||||
|
||||
~String();
|
||||
|
||||
Result<String> clone() const;
|
||||
|
@ -23,6 +23,24 @@ String::String(String&& other)
|
||||
other.m_string = nullptr;
|
||||
}
|
||||
|
||||
String& String::operator=(String&& other)
|
||||
{
|
||||
if (&other == this) return *this;
|
||||
|
||||
if (!m_inline) free_impl(m_string);
|
||||
|
||||
m_inline = other.m_inline;
|
||||
|
||||
m_string = other.m_string;
|
||||
m_length = other.m_length;
|
||||
|
||||
if (m_inline) memcpy(m_inline_storage, other.m_inline_storage, sizeof(m_inline_storage));
|
||||
|
||||
other.m_string = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
String::String(char* c_str)
|
||||
{
|
||||
check(c_str);
|
||||
|
Loading…
Reference in New Issue
Block a user