vector iterator not incrementable For information on how your program can cause an an assertion Failure, see the Visual c + + documentation on asserts
#include <list>
using namespace std; int _tmain(int argc, _TCHAR* argv[])
{
list<int> slist;
list<int>::iterator iter;
slist.push_back(1);
slist.push_back(5);
slist.push_back(11);
for(iter = slist.begin(); iter != slist.end(); ++iter)
{
if(11 == *iter)
slist.erase(iter);
}
return 0;
}
问题(vector iterator not incrementable For information on how your program can cause an an assertion Failure, see the Visual c + + documentation on asserts. (Press Retry to debug the application)
这个比较典型,当删除的元素不是最后一个,则没有太大问题。
VS2008下运行这个,当slist.erase(iter);当要删除的元素是slist中的最后一个的时候,执行erase之后
iter就指向end了,再次进入for循环,执行++iter就出错了。。。(erase会是迭代器失效)
默认的是const iterator 是会出现这种错误的:
判断
if (it != m_Bullsts.end()) //迭代器失效
{
it++;
}
vector iterator not incrementable For information on how your program can cause an an assertion Failure, see the Visual c + + documentation on asserts的更多相关文章
- [转]vector iterator not incrementable 的问题
转自:http://blog.csdn.net/kuaile123/article/details/11105115 vector::erase误使用问题: 暂时使用经验: 不能在循环中使用,否则会报 ...
- C++ error C2440: “类型转换” : 无法从“std::vector::iterator”转换为“
原文地址:http://blog.csdn.net/onlyou930/article/details/5602654 圆环套圆环之迭代器 话说这一日是风平浪静,万里乌云,俺的心情好的没得说,收到命令 ...
- 迭代器类vector::iterator 和 vector::reverse_iterator 的实现、迭代器类型、常用的容器成员
一.迭代器 迭代器是泛型指针 普通指针可以指向内存中的一个地址 迭代器可以指向容器中的一个位置 STL的每一个容器类模版中,都定义了一组对应的迭代器类.使用迭代器,算法函数可以访问容器中指定位置的元素 ...
- STL.vector.iterator的序号
ZC:网上查到,使用vector时,只要将 find到的iterator(itX)减去vector::begin() 就可以得到itX的序号. 1.需求:得到 某个 iterator在 vector中 ...
- ERROR: iterator not incrementable || iterator not decrementable
这个错误提示:迭代器不可以增加 exmaple: vector<int> tVecInt; vector<int>::reverse_iterator iterInt = tV ...
- map set iterator not incrementable 解决办法
例子: #include <iostream> #include <map> using namespace std; int main() { map<int, int ...
- cb37a-_c++_STL_算法_复制元素copy_copy_backward
cb37a-_c++_STL_算法_复制元素copy_copy_backward copy(),同一个容器内部区间的拷贝,或者容器与容器之间的拷贝copy_backward()//向后copy 注意: ...
- opencv 3.2 vs2015 debug assertion __acrt_first_block == header
网上复制了一个转直方图的代码 ,说来也奇怪, 用imshow 显示 图片在独立窗体内,不存在问题, 要注释掉这段代码就出现了下边的错误. 网上查了查,原来是程序中 有个std::vector<c ...
- program files (x86)\microsoft visual studio 14.0\vc\include\xtree,如果没有找到,下标溢出了,就报错咯
---------------------------Microsoft Visual C++ Runtime Library---------------------------Debug Asse ...
随机推荐
- R语言平均值和加权平均值
> a=c(,,) > mean(a) #平均值 [] > wt=c(,,) > weighted.mean(a,wt) #加权平均值 []
- Aras Innovator 11 sp2安装
本文档记录Aras Innovator 11 sp2的安装过程 官方安装文档:http://www.aras.com/support/documentation/ Aras Innovator 11. ...
- destoon 部署到服务器如何修改密码使网站能正常访问登录
1.根目录的config.inc.php 修改 db_pass 2.缓存文件 根目录/file/cache/module-2.php 修改 uc_dbpwd PS:不一定都在module-2.p ...
- CodeForces 731E Funny Game
博弈,$dp$. 设$f[i]$表示 如果先手第一次出手取到位置$i$,直到游戏结束,双方均采取最优策略,先手-后手得分的差值. 那么$f[i]=min(sum[i]-sum[j]+maxf[j+1] ...
- linux文件简单操作
1.vim常用快捷键 dd/ndd 删除1行/删除n行 yy/nyy 复制1行/复制n行 p 粘贴 u 撤销 dw/ndw 删除一个单词/删除n个单词 G /nG 到一行尾/第n行尾 :!+命令 ...
- 差分【bzoj3043】IncDec Sequence
Description 给定一个长度为n的数列{a1,a2...an},每次可以选择一个区间[l,r],使这个区间内的数都加一或者都减一. 问至少需要多少次操作才能使数列中的所有数都一样,并求出在保证 ...
- 解决PHPExcel列超过26的问题
$column = PHPExcel_Cell::stringFromColumnIndex(index);//index对应的就是列,从0开始 $objPHPExcel->getActiveS ...
- 【codevs1074】食物链
[codevs1074]食物链 2001年NOI全国竞赛 时间限制: 3 s 空间限制: 64000 KB 题目等级 : 钻石 Diamond 题目描述 Description 动物王国中有 ...
- 【BFS】【位运算】解药还是毒药
[codevs2594]解药还是毒药 Description Smart研制出对付各种症状的解药,可是他一个不小心,每种药都小小地配错了一点原料,所以这些药都有可能在治愈某些病症的同时又使人患上某些别 ...
- new placement 的使用
#include <iostream> #include "TModel.h" int main() { ]; std::cout<<"Sourc ...