Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](common) implement the move assignment operator for Status #23372

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions be/src/common/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ consteval bool capture_stacktrace(int code) {

class Status {
public:
Status() : _code(ErrorCode::OK) {}
Status() : _code(ErrorCode::OK), _err_msg(nullptr) {}

// copy c'tor makes copy of error detail so Status can be returned by value
Status(const Status& rhs) { *this = rhs; }
Expand All @@ -329,7 +329,13 @@ class Status {
}

// move assign
Status& operator=(Status&& rhs) noexcept = default;
Status& operator=(Status&& rhs) noexcept {
_code = rhs._code;
if (rhs._err_msg) {
_err_msg = std::move(rhs._err_msg);
}
return *this;
}

Status static create(const TStatus& status) {
return Error<true>(status.status_code,
Expand Down
Loading