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
- rvalues (e.g. anonymous lambdas)
- lvalues (e.g. named functors)