From 189927c237cc4cfd38af2da5f25891c30d84e6dc Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 28 Oct 2021 03:52:21 -0400 Subject: [PATCH 1/2] hle/result: Add move assignment operator in ResultVal ResultVal was missing a move assignment operator, add it. --- src/core/hle/result.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/core/hle/result.h b/src/core/hle/result.h index a755008d59..ffef467948 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -244,6 +244,26 @@ public: return *this; } + ResultVal& operator=(ResultVal&& o) { + if (this == &o) { + return *this; + } + if (!empty()) { + if (!o.empty()) { + object = std::move(o.object); + } else { + object.~T(); + } + } else { + if (!o.empty()) { + new (&object) T(std::move(o.object)); + } + } + result_code = o.result_code; + + return *this; + } + /** * Replaces the current result with a new constructed result value in-place. The code must not * be an error code. From 1b5c37fa298f594bfa4f8132b08d1a602d1e5513 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 28 Oct 2021 03:58:41 -0400 Subject: [PATCH 2/2] hle/result: Declare copy/move constructor/assignment as noexcept While we're at it, we can also declare these copy/move constructor/assignment as noexcept. --- src/core/hle/result.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/hle/result.h b/src/core/hle/result.h index ffef467948..00fe709982 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -206,7 +206,7 @@ public: return result; } - ResultVal(const ResultVal& o) : result_code(o.result_code) { + ResultVal(const ResultVal& o) noexcept : result_code(o.result_code) { if (!o.empty()) { new (&object) T(o.object); } @@ -224,7 +224,7 @@ public: } } - ResultVal& operator=(const ResultVal& o) { + ResultVal& operator=(const ResultVal& o) noexcept { if (this == &o) { return *this; } @@ -244,7 +244,7 @@ public: return *this; } - ResultVal& operator=(ResultVal&& o) { + ResultVal& operator=(ResultVal&& o) noexcept { if (this == &o) { return *this; }