progschj / ThreadPool

A simple C++11 Thread Pool implementation
zlib License
7.86k stars 2.24k forks source link

enqueue: capture by universal reference #5

Closed daniel-j-h closed 11 years ago

daniel-j-h commented 11 years ago

Is there a reason the enqueue function doesn't capture the type-deduced function as universal reference? E.g.:

template<typename Function>
auto enqueue(Function&& f) -> std::future<decltype(std::forward<F>(f)())>;

This would allows us to std::forward(f) later on, preserving the rvalue/lvalue type.

This should handle situations nicely where we enqueue

progschj commented 11 years ago

Sorry for the lat answer, I was stuck in the military for a few weeks... The only reason is my still limited knowledge of C++11 ;). I incorporated this in the develop branch.