Caching the end iterator - Good idea or Bad Idea?

前端 未结 8 1845
臣服心动
臣服心动 2021-02-04 03:36

Generally speaking is it a good idea to cache an end iterator (specifically STL containers) for efficiency and speed purposes? such as in the following bit of code:



        
8条回答
  •  耶瑟儿~
    2021-02-04 04:08

    Erasing from a container over which you are currently iterating is always a bad idea. The actual caching of your end iterator is not going to change that.

    h.

提交回复
热议问题