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所指向的元素,返回一个指向被删元素 ...
随机推荐
- Log4j(1.2.17) - hello world
1. Maven 依赖 <dependencies> <dependency> <groupId>log4j</groupId> <artifac ...
- MEF依赖注入调试小技巧!
自从哥的项目使用MEF以来,天天那个纠结啊,甭提了.稍有错误,MEF就报错,但就不告诉你哪错了,大爷的. 后来看了MEFX的相关调试方法,感觉也不太理想,根本不够直观的看到错误原因,也许是没有深入学习 ...
- SQL Server Management Studio的对象资源管理器的使用
1.查看 2.对象资源管理器 3.点到某个表的身上 4.出现以下图片,因为有时动态创建的触发器,刷新表下面的触发器可能不出来,所以来这里面找
- C#读取Visual FoxPro(*.dbf)数据并使用SqlBulkCopy插入到SqlServer 2008 R2数据表中
公司数据库从32位的SqlServer 2005升级到64位的SqlServer 2008 R2后,无法再像原来通过Link Server连接VFP同步数据,因此考虑用代码程序从VFP数据库中读取所需 ...
- elastic search 学习笔记
Elastic search在数据分析的应用中相当于一个数据库的搜索引擎. 跟MySQL类似,它有自己的查询语言,只不过不是关系型数据库,属于NoSQL. 可以根据索引从分布式服务器文件系统中快速存取 ...
- SGU 162.Pyramids
时间限制:0.25s 空间限制:6M; 题意: 按照AB, AC, AD, BC, BD, CD.给出一个空间四面体的6条边长.求出它的体积. Solution: 欧拉四面体公式: ...
- Magento 编译 php5.6.21 命令
./configure '--prefix=/alidata/server/php' '--enable-opcache' '--with-config-file-path=/alidata/ser ...
- RemoteViews嵌入ListView复杂布局
from http://blog.csdn.net/liliang497/article/details/8308313 主要函数 public void setRemoteAdapter (int ...
- openerp report image
webkit : 再mako 文件中插入以下代码, <% %>标签用于再mako中定义代码或者函数. 然后 ${ embed_image('图片类型', 图片字段 , 宽度,高度) } ...
- 关于sql server 代理(已禁用代理xp)
由于有数据库在恢复,导致计划不能执行,先操作如下: 关闭数据库的服务..然后把数据库文件剪切出来.然后在起服务.进入SqlSever删除数据库.因为文件已经剪切走了.所以不会删除文件.再把数据库拷到M ...