mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-27 09:12:46 +01:00
Merge pull request #7241 from Morph1984/resultval-move-assignment
hle/result: Add move assignment operator in ResultVal
This commit is contained in:
commit
c1b199bd21
1 changed files with 22 additions and 2 deletions
|
@ -206,7 +206,7 @@ public:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal(const ResultVal& o) : result_code(o.result_code) {
|
ResultVal(const ResultVal& o) noexcept : result_code(o.result_code) {
|
||||||
if (!o.empty()) {
|
if (!o.empty()) {
|
||||||
new (&object) T(o.object);
|
new (&object) T(o.object);
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal& operator=(const ResultVal& o) {
|
ResultVal& operator=(const ResultVal& o) noexcept {
|
||||||
if (this == &o) {
|
if (this == &o) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -244,6 +244,26 @@ public:
|
||||||
return *this;
|
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
|
* Replaces the current result with a new constructed result value in-place. The code must not
|
||||||
* be an error code.
|
* be an error code.
|
||||||
|
|
Loading…
Reference in a new issue