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 */