do the same with the returning version

master
Daniel Kolesa 2017-03-18 18:53:57 +01:00
parent 3462703b3a
commit 795234c476
1 changed files with 8 additions and 3 deletions

View File

@ -70,9 +70,14 @@ struct thread_pool {
p_cond.notify_one();
} else {
/* non-void-returning funcs return a future */
std::packaged_task<R> t{
std::bind(std::forward<F>(func), std::forward<A>(args)...)
};
std::packaged_task<R> t;
if constexpr(sizeof...(A) == 0) {
t = std::packaged_task<R>{std::forward<F>(func)};
} else {
t = std::packaged_task<R>{
std::bind(std::forward<F>(func), std::forward<A>(args)...)
};
}
auto ret = t.get_future();
std::unique_lock<std::mutex> l{p_lock};
if (!p_running) {