Is there any reason not to send a parameter as a const &
, instead of by value, when it will not be changed and no copy will be made? My understanding is that a const
by value parameter is the same as without the const
(and won't overload each other) so it will still be copied.
I know it's best for large objects to send by const &
, but I don't know where the line for this is. Or if even small parameters should be sent by value if they won't be changed or copied.
Note:: I tried searching for this but the topic is fairly vague so I did not find any good answers, I apologize if this has been answered already (found many questions about when to use const
when to use const &
but not about the advantages of value vs const &
for objects not obviously large).