diff --git a/ostd/thread_pool.hh b/ostd/thread_pool.hh index 86fb43b..e73ff22 100644 --- a/ostd/thread_pool.hh +++ b/ostd/thread_pool.hh @@ -60,9 +60,13 @@ struct thread_pool { if (!p_running) { throw std::runtime_error{"push on stopped thread_pool"}; } - p_tasks.push( - std::bind(std::forward(func), std::forward(args)...) - ); + if constexpr(sizeof...(A) == 0) { + p_tasks.push(std::forward(func)); + } else { + p_tasks.push( + std::bind(std::forward(func), std::forward(args)...) + ); + } p_cond.notify_one(); } else { /* non-void-returning funcs return a future */