From d8012e1678e1706a560e0d73073aace9d7b090c7 Mon Sep 17 00:00:00 2001 From: Peter Thoman Date: Tue, 26 Jul 2022 10:23:52 +0200 Subject: [PATCH] Enable multi_future::get for void multi futures --- BS_thread_pool.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/BS_thread_pool.hpp b/BS_thread_pool.hpp index 629e9d6..810d304 100644 --- a/BS_thread_pool.hpp +++ b/BS_thread_pool.hpp @@ -49,11 +49,12 @@ class [[nodiscard]] multi_future multi_future(const size_t num_futures_ = 0) : f(num_futures_) {} /** - * @brief Get the results from all the futures stored in this multi_future object. + * @brief Get the results from all the futures stored in this multi_future object, re-throwing any stored exceptions. * * @return A vector containing the results. */ - [[nodiscard]] std::vector get() + template + [[nodiscard]] std::enable_if_t, std::vector> get() { std::vector results(f.size()); for (size_t i = 0; i < f.size(); ++i) @@ -61,6 +62,16 @@ class [[nodiscard]] multi_future return results; } + /** + * @brief Get the results from all the void futures stored in this multi_future object, re-throwing any stored exceptions. + */ + template + std::enable_if_t, void> get() + { + for (size_t i = 0; i < f.size(); ++i) + f[i].get(); + } + /** * @brief Wait for all the futures stored in this multi_future object. */