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 | 2864babfa87f733ea32b279bdba4fa0fa1e57b9a (patch) | |
| tree | 4f90a24e7569d8ea5d93ffd028cf19171367f45f /src/core | |
| parent | 1504af343ce78042cbd1a083df37c4f31f148e24 (diff) | |
| parent | 55362bccd9b007bc7a98babb248bf6ffd809f5d1 (diff) | |
Merge pull request #7241 from Morph1984/resultval-move-assignment
hle/result: Add move assignment operator in ResultVal
Diffstat (limited to 'src/core')
| -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 a755008d59..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,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. |
