diff --git a/src/zstring.cpp b/src/zstring.cpp index e9b41a6d7..f4f57c4f3 100644 --- a/src/zstring.cpp +++ b/src/zstring.cpp @@ -211,6 +211,21 @@ FString &FString::operator = (const FString &other) } return *this; } + +FString &FString::operator = (FString &&other) +{ + assert (Chars != NULL); + + if (&other != this) + { + Data()->Release(); + Chars = other.Chars; + other.ResetToNull(); + } + + return *this; +} + FString &FString::operator = (const char *copyStr) { if (copyStr != Chars) diff --git a/src/zstring.h b/src/zstring.h index e7ab098dd..b6986361f 100644 --- a/src/zstring.h +++ b/src/zstring.h @@ -124,6 +124,7 @@ public: // Copy constructors FString (const FString &other) { AttachToOther (other); } + FString (FString &&other) : Chars(other.Chars) { other.ResetToNull(); } FString (const char *copyStr); FString (const char *copyStr, size_t copyLen); FString (char oneChar); @@ -165,6 +166,7 @@ public: const char &operator[] (unsigned long long index) const { return Chars[index]; } FString &operator = (const FString &other); + FString &operator = (FString &&other); FString &operator = (const char *copyStr); FString operator + (const FString &tail) const;