From f07eefaf5af667f284e547df7f583ade4a87fa57 Mon Sep 17 00:00:00 2001 From: q66 Date: Sat, 18 Mar 2017 20:02:03 +0100 Subject: [PATCH] thread_pool push result type fix --- ostd/thread_pool.hh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ostd/thread_pool.hh b/ostd/thread_pool.hh index 24c60e5..2970f10 100644 --- a/ostd/thread_pool.hh +++ b/ostd/thread_pool.hh @@ -18,6 +18,13 @@ namespace ostd { +namespace detail { + template + using task_result_of = std::conditional_t< + std::is_same_v, void, std::future + >; +} + struct thread_pool { void start(size_t size = std::thread::hardware_concurrency()) { p_running = true; @@ -52,7 +59,9 @@ struct thread_pool { } template - auto push(F &&func, A &&...args) -> std::result_of_t { + auto push(F &&func, A &&...args) -> + detail::task_result_of> + { using R = std::result_of_t; if constexpr(std::is_same_v) { /* void-returning funcs return void */