Add an rvalue constructor for Expected (#5087)

to be sure that other expected remains with status 'error checked'
This commit is contained in:
Alexander 2018-08-28 10:53:50 +01:00 committed by GitHub
parent 1103d2cf24
commit be73ffe618
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,12 +98,14 @@ class Expected final {
explicit Expected(ErrorCodeEnumType code, std::string message)
: object_{ErrorType(code, message)} {}
Expected(Expected&& other) = default;
Expected() = delete;
Expected(const Expected&) = delete;
Expected(ErrorBase* error) = delete;
Expected(Expected&& other)
: object_(std::move(other.object_)), errorChecked_(other.errorChecked_) {
other.errorChecked_.set(true);
}
Expected& operator=(Expected&& other) {
if (this != &other) {
errorChecked_.verify("Expected was not checked before assigning");
@ -115,6 +117,7 @@ class Expected final {
return *this;
}
Expected(const Expected&) = delete;
Expected& operator=(const Expected& other) = delete;
~Expected() {