From 5a1defa4ff1b8a88c7a018f9f65cd85028a8a025 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 20 Jun 2020 02:58:32 -0500 Subject: [PATCH] [ox/std] Add move operator to String (synced from 257e85711687be985ce036ed2311ce6cf3fdc0b9) --- src/ox/std/string.cpp | 5 +++++ src/ox/std/string.hpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/ox/std/string.cpp b/src/ox/std/string.cpp index 812776718..18d1b9bbe 100644 --- a/src/ox/std/string.cpp +++ b/src/ox/std/string.cpp @@ -70,6 +70,11 @@ const String &String::operator=(const String &src) noexcept { return *this = src.c_str(); } +const String &String::operator=(const String &&src) noexcept { + m_buff = ox::move(src.m_buff); + return *this; +} + const String &String::operator+=(const char *str) noexcept { std::size_t strLen = ox_strlen(str); auto currentLen = len(); diff --git a/src/ox/std/string.hpp b/src/ox/std/string.hpp index b0d932fa8..67b468e5f 100644 --- a/src/ox/std/string.hpp +++ b/src/ox/std/string.hpp @@ -41,6 +41,8 @@ class String { const String &operator=(const String &src) noexcept; + const String &operator=(const String &&src) noexcept; + const String &operator+=(const char *str) noexcept; const String &operator+=(char *str) noexcept;