Skip to content

Commit

Permalink
[fix](common) implement the move assignment operator for Status (apac…
Browse files Browse the repository at this point in the history
  • Loading branch information
AshinGau authored Aug 24, 2023
1 parent 303d5ac commit c6ac925
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit c6ac925

Please sign in to comment.