early-access version 2166

This commit is contained in:
pineappleEA
2021-10-29 19:27:16 +02:00
parent 55673479db
commit 5df35c4982
8 changed files with 77 additions and 27 deletions

View File

@@ -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.