I keep seeing patterns as:
template<class Task, class ...Args>
void add(Task&& task, Args&& ... args) {
queue.emplace_back(std::bind(std::forward<Task>(task),std::forward<Args>(args)...));
From what I understand, functions are pretty much every time passed via a function pointer, so is there any value in forwarding it if there is only one option (maybe if passed by reference, but not sure why we would do this)?
Similarly, why do people perfect forward to bind()
? Am I missing something, or it is just a commonly occurring bug? I thought that bind()
will always accept by value and hence copy whatever you pass it?