From acaedc4dfb438e215d86474b092a7a2d5b2d0b6c Mon Sep 17 00:00:00 2001 From: gaoxin Date: Wed, 23 Aug 2023 16:14:46 +0800 Subject: [PATCH] [fix](common) implement the move assignment operator for Status --- 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 968dbeb9e91d2a..02b8e79053e5a3 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 @@ 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(status.status_code,