According to Wikipedia, function calls don’t copy parameters which are are references to a const type:
void f_slow(BigObject x);
void f_fast(const BigObject& x);
f_slow(y); // slow, copies y to parameter x
f_fast(y); // fast, gives direct read-only access to y
Why does the reference need to be const? Wouldn’t a non-const reference accomplish the same:
void f_should_be_fast(BigObject& x);
Yes, any kind of reference will do. Making it
constmakes it more flexible as it can accept const variables or temporaries as parameters, and documents (and enforces) your intent not to modify the parameter.