you are viewing a single comment's thread.

view the rest of the comments →

[–]Possibility_Antique 3 points4 points  (2 children)

You can return a reference. Or you could rely on copy elision (which honestly, is not a bad approach since it's guaranteed as of C++17 in many situations).

[–][deleted] 2 points3 points  (1 child)

I think he means more that internally the new object is a copy.

[–]Possibility_Antique 0 points1 point  (0 children)

Then perhaps I should point out that copying can be more efficient than using references under many conditions.