diff --git a/ostd/thread_pool.hh b/ostd/thread_pool.hh index e73ff22..24c60e5 100644 --- a/ostd/thread_pool.hh +++ b/ostd/thread_pool.hh @@ -70,9 +70,14 @@ struct thread_pool { p_cond.notify_one(); } else { /* non-void-returning funcs return a future */ - std::packaged_task t{ - std::bind(std::forward(func), std::forward(args)...) - }; + std::packaged_task t; + if constexpr(sizeof...(A) == 0) { + t = std::packaged_task{std::forward(func)}; + } else { + t = std::packaged_task{ + std::bind(std::forward(func), std::forward(args)...) + }; + } auto ret = t.get_future(); std::unique_lock l{p_lock}; if (!p_running) {