diff options
author | bunnei <bunneidev@gmail.com> | 2021-10-29 09:14:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 09:14:32 -0700 |
commit | c1b199bd21d32a20fead3d157f9e01f92534af77 (patch) | |
tree | 4f90a24e7569d8ea5d93ffd028cf19171367f45f /src | |
parent | 60e79d50f8e30c7c498f3fc391348764d9fec7de (diff) | |
parent | 1b5c37fa298f594bfa4f8132b08d1a602d1e5513 (diff) |
Merge pull request #7241 from Morph1984/resultval-move-assignment
hle/result: Add move assignment operator in ResultVal
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hle/result.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/core/hle/result.h b/src/core/hle/result.h index a755008d5..00fe70998 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,6 +244,26 @@ public: return *this; } + ResultVal& operator=(ResultVal&& o) noexcept { + 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. |