vector::erase returns incompatible iterator in debug build
关于std::vector中erase的用法http://www.cplusplus.com/reference/vector/vector/erase/
#include <vector>
struct WordCoordinate {
int x;
int y;
int z;
};
struct Mypoint
{
int x;
int y;
};
int main()
{
std::vector<WordCoordinate> m_worldCoorPoint;
std::vector<Mypoint> m_screenPoint;
Mypoint point;
for (int i=;i<=;i++)
{
WordCoordinate m_w;
m_w.x=+i;
m_w.y=+i;
m_w.z=+i;
m_worldCoorPoint.push_back(m_w);
point.x = i+;
point.y = i+;
m_screenPoint.push_back(point);
point.x = *i+;
point.y = *i+;
m_screenPoint.push_back(point);
} int thershold =; // if distance low than thershold delete the point
std::vector<WordCoordinate>::iterator itw=m_worldCoorPoint.begin();
std::vector<Mypoint>::iterator it=m_screenPoint.begin();
int idex = ;
while(it!=m_screenPoint.end())
{ printf("delete point index %d\n",idex);
printf("cur point (%d %d)",(*it).x,(*it).y); if( idex==)
{ it=m_screenPoint.erase(it,it+);
itw=m_worldCoorPoint.erase(itw);
} idex++;
}
system("pause");
return ;
}
当程序运行到if( idex==2)后再返回while就会出错,这个是微软官方bug http://connect.microsoft.com/VisualStudio/feedback/details/545013解决方法安装sp1
在这个版本下会有错:时间有限来不及详细写,有空补充bug原因

vector::erase returns incompatible iterator in debug build的更多相关文章
- stl vector erase
C++ Code 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 ...
- MSDN 中 对vector::erase()的解释.xml
pre{ line-height:1; color:#f0caa6; background-color:#2d161d; font-size:16px;}.sysFunc{color:#e54ae9; ...
- C++中使用vector.erase()需要注意的事项
本人菜鸟一枚.. 今天在用vector.erase()的时候,发现总是不能把应该erase掉的东西erase干净. 举个栗子: vector<int> num_vec; num_vec.p ...
- vector.erase用法注意事项
转自->这里 vector::erase():从指定容器删除指定位置的元素或某段范围内的元素 vector::erase()方法有两种重载形式 如下: iterator erase(iterat ...
- vector erase
vector::erase 从指定容器删除指定的元素 两个重载: iterator erase (iterator position);删除指定位置position的元素,并返回删除元素的下一个元素的 ...
- vector.erase();vector.clear();map.erase();
vector::erase()返回下一个iter: STL中的源码: //清除[first, last)中的所有元素 iterator erase(iterator first, iterator l ...
- map/vector erase
问题核心:erase之后迭代器是否失效 vector调用erase之后,该迭代器之后的迭代器都失效: map调用erase之后,其他迭代器并不会失效. vector<int> vecDat ...
- 解决 React-Native mac 运行报错 error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by ope
React-Native 开发的项目,Android 方面没有任何问题,IOS 就是无法跑起来,报错信息如下: mac 10.14.4 xcode 10.2.1 error Failed to bui ...
- C++ vector erase函数的使用注意事项
最近使用了顺序容器的删除元素操作,特此记录下该函数的注意事项. 在C++primer中对c.erase(p) 这样解释的: c.erase(p) 删除迭代器p所指向的元素,返回一个指向被删元素 ...
随机推荐
- 从创建webservice到发布webservice的一些相关总结
最近做了一个web服务,开始什么也不懂,就在网上到处找,对于刚毕业的我,感觉没用实际代码经过自己的手写出来,看什么都一头雾水,然后就看到很多人说webservice已经融入WCF..然后就先创建了WC ...
- 17、SQL Server 备份和还原
SQL Server 备份 恢复模式 SQL Server 数据恢复模式分为三种:完整恢复模式.大容量日志恢复模式.简单恢复模式. 完整恢复模式 默认的恢复模式,它会完整记录下操作数据库的每一个步骤, ...
- js分家效应
(原创文章,转载请注明出处) 有继承,那么就有分家.让我们看以下例子. var parents = function(){ } parents.prototype.money = 200; var c ...
- webUploader上传组件 实际运用小结
WebUploader组件实际介绍: 官网:http://fex.baidu.com/webuploader/doc/index.html 组件优势及优化总结:http://itindex.net/d ...
- Hessian(C#)介绍及使用说明
什么是Hessian? Hessian是Caucho开发的一种二进制Web Service协议.支持目前所有流行的开发平台. Hessia能干什么? hessian用来实现web服务. Hessia有 ...
- sp_addlinkedserver的一些操作
sp_addlinkedserver 创建一个链接的服务器,使其允许对分布式的.针对 OLE DB 数据源的异类查询进行访问.在使用 sp_addlinkedserver 创建链接的服务器之后,此服务 ...
- 解决Xcode7多个模拟器的方法
xcode模拟器都这样显示,没办法判断是哪个系统,解决办法是 1.关闭xcode 2.终端输入 sudo killall -9 com.apple.CoreSimulator.CoreSimulato ...
- [C++]C++类基本语法
本测试代码包括以下内容: (1)如何使用构造函数:(2)默认构造函数:(3)对象间赋值:(4)const使用语法:(5)定义类常量: 一种方法是用enum,另一种方法是使用static. #inclu ...
- POJ 3468.A Simple Problem with Integers 解题报告
用树状数组和线段树会比较简单,这里用这道题来学习Splay. 第一次写,代码比较丑 /* 初始化添加一个key值足够大的结点 保证每个需要的结点都有后继 */ #include <iostrea ...
- JS设置Cookie,及COOKIE的限制
在Javascript脚本里,一个cookie 实际就是一个字符串属性.当你读取cookie的值时,就得到一个字符串,里面当前WEB页使用的所有cookies的名称和值.每个cookie除了 name ...