标签:需要 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