Can end() be a costly operation for stl containers

后端 未结 7 1952
囚心锁ツ
囚心锁ツ 2020-12-16 12:16

On https://doc-snapshots.qt.io/qtcreator-extending/coding-style.html it is recommended to write for loops like the following:

Container::iterator end = large         


        
相关标签:
7条回答
  • 2020-12-16 12:49

    If you plan to modify the collection as you iterate, you have to do it the 2nd way (end can change) - otherwise the first is theoretically a fraction faster. I doubt it would be noticeable though.

    0 讨论(0)
提交回复
热议问题