Cost of passing by reference when a template type is fundamental
I've always heard that a good practice to ensure best performance was to: pass fundamental types ( int , double ...) by value pass classes by const reference Nowadays, using C++11 and full optimizations under a compiler, is there an overhead when one passes a fundamental type by const reference? And furthermore, when T is int will the following function: template <typename T> inline void f(const T& x); be slower than: template <typename T> inline void f(const T x); If the compiler is really inlining the code (which is common for simple templates) there will be no difference. The problem