Skip to content

Commit

Permalink
[fix](common) implement the move assignment operator for Status (#23372)
Browse files Browse the repository at this point in the history
  • Loading branch information
AshinGau authored and xiaokang committed Aug 24, 2023
1 parent 7af8619 commit ba396d7
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 @@ -314,7 +314,7 @@ inline 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 @@ -332,7 +332,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 ba396d7

Please sign in to comment.