码迷,mamicode.com
首页 > 其他好文 > 详细

List的遍历——list iterator not incrementable

时间:2016-11-04 17:15:23      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:需要   else   tin   blog   ble   for   type   操作   reg   

 1 for ( std::list<Type>::iterator it =ObjList.begin(); it != ObjList.end(); )
 2 {
 3        if((*it->regin == CheckRegin )
 4        {
 5               it= ObjList.earse(it);
 6               continue;
 7        }
 8 
 9        else
10       {
11               ++it;
12       }
13 }

List在erase后原来的遍历器就失效了,不能再往下执行,需要continue跳出本次循环。earse操作会返回一个指向container下一个元素的iterator,如果想继续遍历,就得用返回的iterator继续操作。

List的遍历——list iterator not incrementable

标签:需要   else   tin   blog   ble   for   type   操作   reg   

原文地址:http://www.cnblogs.com/yuan1164345228/p/6030642.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!