Is there anything to be gained by using const int &var
formal parameters in place of const int var
?
I know the advantage in large structs but for PODs the pointer is often of equal size to the actual data. So I guess the answer would be "No advantage". But I think perhaps the pass by value semantics copies once to the stack and again to an area off the stack for easier reference (say to a register). Or maybe not. In fact it may infact be better to pass by value,
http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/
Because references are typically implemented by C++ using pointers, and dereferencing a pointer is slower than accessing it directly, accessing values passed by reference is slower than accessing values passed by value.
But this gets back to what I was saying about copying back off the stack. I'm just being paranoid right? This behaviour is for the compiler to worry about and not me.
I could single step the assembly I know, but, well, googling is faster and it came up blank.