Scott Meyers says in "Effective Modern C++" that the expression
Matrix sum = m1 + m2 + m3 + m4
(where all objects have type 'Matrix') "can be computed much more efficiently if operator+
for Matrix
objects returns a proxy for the result instead of the result itself. That is, operator+
for two Matrix
objects would return an object of a proxy class such as Sum
instead of a Matrix
object.".
Now, I understand that proxy classes emulate behaviour of some other classes and do implicit converisons, but how and why is proxy approach in this case more efficient?
Best regards
Aucun commentaire:
Enregistrer un commentaire