In C++98 I got used to using call_traits in my templated functions to automatically pick the best way to pass parameters, e.g.:
template<class T>
void foo(typename boost::call_traits<T>::param_type arg)
{
// .. do stuff with arg ..
}
The advantage being that for primitives it would pass by value and for more complex objects it would pass by reference, so I'd have the least amount of overhead possible. C++11 now has a concept of 'universal references':
template<class T>
void foo(T&& arg)
{
// .. do stuff with arg ..
}
As I understand it I need to use a universal reference in order to get perfect forwarding with std::forward, so if I plan to use that the choice is clear. But when I don't plan to, which should I prefer? Will a universal reference always be as good or better?