Pass by value or const reference? [duplicate]
问题 This question already has answers here : Are the days of passing const std::string & as a parameter over? (13 answers) Closed 6 years ago . There is a set of good rules to determine whether pass by value or const reference If the function intends to change the argument as a side effect, take it by non-const reference. If the function doesn't modify its argument and the argument is of primitive type, take it by value. Otherwise take it by const reference, except in the following cases: If the