mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 18:08:53 +00:00
Add an rvalue constructor for Expected (#5087)
to be sure that other expected remains with status 'error checked'
This commit is contained in:
parent
1103d2cf24
commit
be73ffe618
@ -98,12 +98,14 @@ class Expected final {
|
|||||||
explicit Expected(ErrorCodeEnumType code, std::string message)
|
explicit Expected(ErrorCodeEnumType code, std::string message)
|
||||||
: object_{ErrorType(code, message)} {}
|
: object_{ErrorType(code, message)} {}
|
||||||
|
|
||||||
Expected(Expected&& other) = default;
|
|
||||||
|
|
||||||
Expected() = delete;
|
Expected() = delete;
|
||||||
Expected(const Expected&) = delete;
|
|
||||||
Expected(ErrorBase* error) = delete;
|
Expected(ErrorBase* error) = delete;
|
||||||
|
|
||||||
|
Expected(Expected&& other)
|
||||||
|
: object_(std::move(other.object_)), errorChecked_(other.errorChecked_) {
|
||||||
|
other.errorChecked_.set(true);
|
||||||
|
}
|
||||||
|
|
||||||
Expected& operator=(Expected&& other) {
|
Expected& operator=(Expected&& other) {
|
||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
errorChecked_.verify("Expected was not checked before assigning");
|
errorChecked_.verify("Expected was not checked before assigning");
|
||||||
@ -115,6 +117,7 @@ class Expected final {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Expected(const Expected&) = delete;
|
||||||
Expected& operator=(const Expected& other) = delete;
|
Expected& operator=(const Expected& other) = delete;
|
||||||
|
|
||||||
~Expected() {
|
~Expected() {
|
||||||
|
Loading…
Reference in New Issue
Block a user