From b88c784634f46d63cbd7e09074bf388bfe9afbde Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 6 Sep 2019 18:53:10 +0300 Subject: [PATCH] Improved circular_q move --- include/spdlog/details/circular_q.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/spdlog/details/circular_q.h b/include/spdlog/details/circular_q.h index 5bcd8697..72d9bf65 100644 --- a/include/spdlog/details/circular_q.h +++ b/include/spdlog/details/circular_q.h @@ -88,13 +88,19 @@ public: } private: - void copy_moveable(circular_q &&other) SPDLOG_NOEXCEPT + // copy from other&& and reset it to disabled state + void copy_moveable(circular_q &&other) SPDLOG_NOEXCEPT { max_items_ = other.max_items_; head_ = other.head_; tail_ = other.tail_; - overrun_counter_ = other.overrun_counter_, v_ = std::move(other.v_); - other.max_items_ = 0; // disable other + overrun_counter_ = other.overrun_counter_; + v_ = std::move(other.v_); + + // put &&other in disabled, but valid state + other.max_items_ = 0; + other.head_ = other.tail_ = 0; + other.overrun_counter_ = 0; } }; } // namespace details