Are const_iterators faster?

后端 未结 11 1869
挽巷
挽巷 2020-11-30 02:04

Our coding guidelines prefer const_iterator, because they are a little faster compared to a normal iterator. It seems like the compiler optimizes t

11条回答
  •  借酒劲吻你
    2020-11-30 02:31

    If nothing else, a const_iterator reads better, since it tells anyone reading the code "I'm just iterating over this container, not messing with the objects contained".

    That's a great big win, never mind any performance differences.

提交回复
热议问题