Possible Duplicate:
template pass by value or const reference or…?
What is the good practice in the following for a function taking a function as a parameter :
template<class Function> void test1(Function f);
template<class Function> void test2(Function& f);
template<class Function> void test3(const Function& f);
where the passed function can be a functor, a std::function, a function pointer or a lambda function.
Use universal references and you won’t need to think about it: