Efficiency of output parameter vs return value on the stack for stl data structures
问题 lets say I have the functions std::Vector<Point> calculate() { std::Vector<Point> points; //do stuff with points return points; } and void calculate(std::Vector<Point>& points) { //do stuff with points } So my question is specific to objects initialized on the stack, and are stl objects. Is there any difference in performance, and what is the popular method of doing it regards 回答1: Taking the value as a reference parameter has the following properties: No copying, moving, or any other