Solution: Don’t ever pass temporary object by reference.
Reason: C++ doesn't allow to bind the temporary object with non-const reference.
This is not about performance, but about the fact that you do or may alter the original, which you are not allowed to if that original is a temporary. Passing by value instead of by reference, we wouldn't have the problem.
No comments:
Post a Comment