All this talk of named objects, unnamed objects, and compiler optimizations is interesting, but let us not forget the big picture. The big picture is that assignment versions of operators (such as operator+=
) tend to be more efficient than stand-alone versions of those operators (e.g. operator+
). As a library designer, you should offer both, and as an application developer, you should consider using assignment versions of operators instead of stand-alone versions whenever performance is at a premium.
Item 22: Consider using op= instead of stand-alone op.(More Effective C++)
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:Item 20: Facilitate the return value optimization.(More Effective C++)
下一篇:Item 18: Amortize the cost of expected computations.(More Effective C++)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
G049-OP-COA-OPEN-12 OpenStack Skyline 对你说:请问我够优雅漂亮吗?
Skyline部署及访问
openstack skyline