From c6ac925f5a8bf55f30686f3549ecbf4e5d9c4ff3 Mon Sep 17 00:00:00 2001 From: Ashin Gau Date: Thu, 24 Aug 2023 14:41:19 +0800 Subject: [PATCH] [fix](common) implement the move assignment operator for Status (#23372) --- be/src/common/status.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/be/src/common/status.h b/be/src/common/status.h index 968dbeb9e9..02b8e79053 100644 --- a/be/src/common/status.h +++ b/be/src/common/status.h @@ -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; } @@ -329,7 +329,13 @@ public: } // 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(status.status_code,