Closed jared-schmitz closed 11 years ago
Code such as this will fail in template deduction:
auto member_task = TP.enqueue(&MyClass::member_func, this);
std::result_of uses std::declval to get the proper result.
Changing the declaration of ThreadPool::enqueue to:
template <class F, class... Args> auto enqueue(F&& f, Args&&... args) -> std::future<typename std::result_of<F(Args...)>::type>;
allows the above to compile. Similarly change the typedef inside the definition.
If I felt I had more expertise in template metaprogramming, I would have submitted a patch. But I may have omitted std::forward in places where it matters.
Seems I never tried using member pointers with it. Using result_of looks way cleaner anyway. Nice!
ac2a77d5cc04361d341f63b1d19706a4d1b4943e
Looks like this is merged!
Code such as this will fail in template deduction:
auto member_task = TP.enqueue(&MyClass::member_func, this);
std::result_of uses std::declval to get the proper result.
Changing the declaration of ThreadPool::enqueue to:
allows the above to compile. Similarly change the typedef inside the definition.
If I felt I had more expertise in template metaprogramming, I would have submitted a patch. But I may have omitted std::forward in places where it matters.