Is writing foo(const float&) wasted effort?

c++

Solution

For floats? Yes, pretty much.

There's simply nothing to gain here: floats are small and the copy will not be slower than the creation of a pointer to implement the reference.

Problem

When passing primitive types like int or float, is it wasted effort to write something like this: ``` foo(const float&); ``` rather than just passing by value: ``` foo(float); ```

Original source

Related problems