diff options
| author | 2021-10-29 09:14:32 -0700 | |
|---|---|---|
| committer | 2021-10-29 09:14:32 -0700 | |
| commit | c1b199bd21d32a20fead3d157f9e01f92534af77 (patch) | |
| tree | 4f90a24e7569d8ea5d93ffd028cf19171367f45f /src | |
| parent | Merge pull request #7243 from lat9nq/nvdrv-warn (diff) | |
| parent | hle/result: Declare copy/move constructor/assignment as noexcept (diff) | |
| download | yuzu-c1b199bd21d32a20fead3d157f9e01f92534af77.tar.gz yuzu-c1b199bd21d32a20fead3d157f9e01f92534af77.tar.xz yuzu-c1b199bd21d32a20fead3d157f9e01f92534af77.zip | |
Merge pull request #7241 from Morph1984/resultval-move-assignment
hle/result: Add move assignment operator in ResultVal
Diffstat (limited to '')
| -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: | |||
| 206 | return result; | 206 | return result; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | ResultVal(const ResultVal& o) : result_code(o.result_code) { | 209 | ResultVal(const ResultVal& o) noexcept : result_code(o.result_code) { |
| 210 | if (!o.empty()) { | 210 | if (!o.empty()) { |
| 211 | new (&object) T(o.object); | 211 | new (&object) T(o.object); |
| 212 | } | 212 | } |
| @@ -224,7 +224,7 @@ public: | |||
| 224 | } | 224 | } |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | ResultVal& operator=(const ResultVal& o) { | 227 | ResultVal& operator=(const ResultVal& o) noexcept { |
| 228 | if (this == &o) { | 228 | if (this == &o) { |
| 229 | return *this; | 229 | return *this; |
| 230 | } | 230 | } |
| @@ -244,6 +244,26 @@ public: | |||
| 244 | return *this; | 244 | return *this; |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | ResultVal& operator=(ResultVal&& o) noexcept { | ||
| 248 | if (this == &o) { | ||
| 249 | return *this; | ||
| 250 | } | ||
| 251 | if (!empty()) { | ||
| 252 | if (!o.empty()) { | ||
| 253 | object = std::move(o.object); | ||
| 254 | } else { | ||
| 255 | object.~T(); | ||
| 256 | } | ||
| 257 | } else { | ||
| 258 | if (!o.empty()) { | ||
| 259 | new (&object) T(std::move(o.object)); | ||
| 260 | } | ||
| 261 | } | ||
| 262 | result_code = o.result_code; | ||
| 263 | |||
| 264 | return *this; | ||
| 265 | } | ||
| 266 | |||
| 247 | /** | 267 | /** |
| 248 | * Replaces the current result with a new constructed result value in-place. The code must not | 268 | * Replaces the current result with a new constructed result value in-place. The code must not |
| 249 | * be an error code. | 269 | * be an error code. |