What happens to an STL iterator after erasing it in VS, UNIX/Linux?

前端 未结 4 688
轻奢々
轻奢々 2020-12-05 21:35

Please consider the following scenario:


map(T,S*) & GetMap(); //Forward decleration

map(T, S*) T2pS = GetMap();

for(map(T, S*)::iterator it = T2pS.begin()         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 21:43

    I think if you modify the collection you invalidate your iterator. You can't rely on the behavior, as you found out.

提交回复
热议问题