+1  A: 

Look at this link which describes exactly what you want to know. Basically, if you have to do the copy, pass by value.

Alexandre C.
+1  A: 

If you pass by non-const reference, you're saying that your function will modify the argument passed.

If you pass by const reference, then don't forget that the cost of passing will be a copy of a pointer (in almost all implementations), so it's not worth if you're passing an basic type.

Klaim
I would change it to read "that your function _may_ modify." Even at that, it's contractual, as I can still do it inside the function with a cost_cast, if I want to be evilly stupid.
San Jacinto
More importantly, if you pass by const reference, you won't be able to call any non-const methods, even if they don't modify the object.
Niki Yoshiuchi
Well, that's why those methods should be declared const in the first place.
ypnos
+3  A: 

Sure.

Suppose all you want to do is pass in the value of an int. If it is passed by value then then that value gets pushed on the stack (or put in a register, however your calling convention does it). On the inside the value is retrieved straight into its destination register ready for use.

If you were instead to pass it by const reference, what gets passed in is the address of where the program can go to find the value when it wants it. That means in order to get the actual value, your program will have to do an entire extra memory fetch. It doesn't take much extra time, but it is more work that wasn't really needed.

Also, with a value pass you are utterly breaking any dependency between caller and callee at the point of the call. That means that when compiling the caller's code, the compiler may safely ignore anything the caller might do to or need from that variable outside of that one point where the call is made. With a reference parameter (even a const one), the compiler now has to worry about what might happen if for example the caller saves off the address of that variable for later use by other routines in other source files. The result is that is is much easier to optimize the caller's code when value passing is used, and the compiler is liable to be able to do a better job of it.

T.E.D.
+1 for the example. On the other hand, the c++ memory model is single threaded, the compiler does not need to consider whether a given variable can be modified externally unless that variable is marked as `volatile`. Then again... the compiler can decide to make a local parameter `register` while it cannot do that with a reference, so at the end of the day, there are small differences for the optimizer.
David Rodríguez - dribeas