diff --git a/include/indicators/dynamic_progress.hpp b/include/indicators/dynamic_progress.hpp index 49d7d89..7340a79 100644 --- a/include/indicators/dynamic_progress.hpp +++ b/include/indicators/dynamic_progress.hpp @@ -19,10 +19,10 @@ template class DynamicProgress { using Settings = std::tuple; public: - template explicit DynamicProgress(Indicators &... bars) { - bars_ = {bars...}; + template explicit DynamicProgress(Indicators &&... bars) { + (bars_.emplace_back(std::move(bars)), ...); for (auto &bar : bars_) { - bar.get().multi_progress_mode_ = true; + bar->multi_progress_mode_ = true; ++total_count_; ++incomplete_count_; } @@ -31,13 +31,13 @@ public: Indicator &operator[](size_t index) { print_progress(); std::lock_guard lock{mutex_}; - return bars_[index].get(); + return *bars_[index]; } - size_t push_back(Indicator &bar) { + size_t push_back(std::unique_ptr bar) { std::lock_guard lock{mutex_}; - bar.multi_progress_mode_ = true; - bars_.push_back(bar); + bar->multi_progress_mode_ = true; + bars_.push_back(std::move(bar)); return bars_.size() - 1; } @@ -63,7 +63,7 @@ private: Settings settings_; std::atomic started_{false}; std::mutex mutex_; - std::vector> bars_; + std::vector> bars_; std::atomic total_count_{0}; std::atomic incomplete_count_{0}; @@ -93,8 +93,8 @@ public: } incomplete_count_ = 0; for (auto &bar : bars_) { - if (!bar.get().is_completed()) { - bar.get().print_progress(true); + if (!bar->is_completed()) { + bar->print_progress(true); std::cout << "\n"; ++incomplete_count_; } @@ -106,7 +106,7 @@ public: if (started_) move_up(static_cast(total_count_)); for (auto &bar : bars_) { - bar.get().print_progress(true); + bar->print_progress(true); std::cout << "\n"; } if (!started_) @@ -119,4 +119,4 @@ public: } // namespace indicators -#endif \ No newline at end of file +#endif