Joaquín Mª López Muñoz
Ben Hutchings ha escrito: <snip>
Without knowing what it is you are trying to do, I cannot offer a workaround.
With pleasure. My original design was
template<typename Type> void foo(const Type& x) { }
(of course the actual code does something useful) and I wanted to take advantage of the call_traits<>::param_type optimization for basic types.
So, no way? Should I revert to const Type&? Some clever workaround to help the compiler swallow the construct? Thx in advance.
I would leave it as const Type &. If you think your compiler is not smart enough to make a local copy of what x refers to when Type when that's likely to improve performance, you could use something like this: template<typename Type> void foo(const Type & arg_x) { typename boost::call_traits<Type>::param_type local_x = arg_x; ... }