4 ms·
Can you explain why this is actually a problem? Why not just always have a const T&, is there some negative in the "cheap copy" case to not copy?
by esrauch 14y ago
Can you explain why this is actually a problem? Why not just always have a const T&, is there some negative in the "cheap copy" case to not copy?
- matthavener 14y agoI'm making some assumptions about the compiler optimization: If T is something like "int", then passing by reference can be more costly, because a value that was once stored in a register now needs a real memory address and must be deferenced to read.