added missing std::forwards to decltype based stuff
the previous version could have caused some minor trouble in extreme edge-cases
This commit is contained in:
parent
ccb0173877
commit
4cd6eb4e2f
@ -70,10 +70,10 @@ public:
|
||||
/* adding tasks to the queue */
|
||||
// TODO: use template-based policies to deal with priority tasks to avoid code-dupe.
|
||||
template <typename F, typename... Args>
|
||||
auto add_task(F&& f, Args&&... args) -> std::future<decltype(f(args...))>;
|
||||
auto add_task(F&& f, Args&&... args) -> std::future<decltype(f(std::forward<Args>(args)...))>;
|
||||
|
||||
template <typename F, typename... Args>
|
||||
auto priority_task(F&& f, Args&&... args) -> std::future<decltype(f(args...))>;
|
||||
auto priority_task(F&& f, Args&&... args) -> std::future<decltype(f(std::forward<Args>(args)...))>;
|
||||
|
||||
template <typename R> void add_task(std::packaged_task<R()>& );
|
||||
template <typename R> void priority_task(std::packaged_task<R()>& );
|
||||
@ -107,9 +107,9 @@ thread_pool::~thread_pool()
|
||||
|
||||
template <typename F, typename... Args>
|
||||
auto thread_pool::add_task(F&& f, Args&&... args)
|
||||
-> std::future<decltype(f(args...))>
|
||||
-> std::future<decltype(f(std::forward<Args>(args)...))>
|
||||
{
|
||||
auto pckgd_tsk = std::make_shared<std::packaged_task<decltype(f(args...))()> >
|
||||
auto pckgd_tsk = std::make_shared<std::packaged_task<decltype(f(std::forward<Args>(args)...))()> >
|
||||
(std::bind(std::forward<F>(f), std::forward<Args>(args)...));
|
||||
|
||||
{
|
||||
@ -123,9 +123,9 @@ auto thread_pool::add_task(F&& f, Args&&... args)
|
||||
|
||||
template <typename F, typename... Args>
|
||||
auto thread_pool::priority_task(F&& f, Args&&... args)
|
||||
-> std::future<decltype(f(args...))>
|
||||
-> std::future<decltype(f(std::forward<Args>(args)...))>
|
||||
{
|
||||
auto pckgd_tsk = std::make_shared<std::packaged_task<decltype(f(args...))()> >
|
||||
auto pckgd_tsk = std::make_shared<std::packaged_task<decltype(f(std::forward<Args>(args)...))()> >
|
||||
(std::bind(std::forward<F>(f), std::forward<Args>(args)...));
|
||||
|
||||
auto ret_val= pckgd_tsk->get_future();
|
||||
|
Loading…
Reference in New Issue
Block a user