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所指向的元素,返回一个指向被删元素 ...
随机推荐
- 对 Xcode 菜单选项的详细探索(转)
转自 http://www.cnblogs.com/dsxniubility/p/4983614.html 本文调研Xcode的版本是 7.1,基本是探索了菜单的每一个按钮.虽然从xcode4一直用到 ...
- ios手势复习值之换图片-转场动画(纯代码)
目标:实现通过手势进行图片的切换 通过左扫右扫 来实现(纯代码) 添加三个属性 1uiImageView 用来显示图片的view 2 index 用来表示图片的索引 3 ISLeft 判断是不是向 ...
- C#模拟POST提交表单(二)--HttpWebRequest以及HttpWebResponse
上次介绍了用WebClient的方式提交POST请求,这次,我继续来介绍用其它一种方式 HttpWebRequest以及HttpWebResponse 自认为与上次介绍的WebClient最大的不同之 ...
- javascript的框架演化
说起javascript不同的人或许有不同的看法,一些资深后台程序员在刚开始的时候根本没有把它当作是一门编程语言,但是随着后面js框架的出现,以及面向对象的程序设计,还有原型,闭包的不断使用,后台程序 ...
- Java学习----this和super(在继承中)
public class Base { /*public Base() { System.out.println("Base 类的初始构造方法"); }*/ public Base ...
- 浏览器兼容性判定写法格式(ie)
条件注释判断浏览器<!--[if !IE]><!--[if IE]><!--[if lt IE 6]><!--[if gte IE 6]> <!- ...
- POJ1258-Agri-Net-ACM
Description Farmer John has been elected mayor of his town! One of his campaign promises was to brin ...
- C#【数据库】 Access类
using System; using System.Data; using System.Data.OleDb; namespace AccessDb { /**//// <summary&g ...
- yum版本新增包的一般步骤
在Jekins的自动构建环境中,有时会有在构建出的ISO中添加新应用app需求,对于采用rpm包源代码管理方式的构建环境来说,基本步骤如下: 1.下载app的src.rpm包 2.解压src.rpm包 ...
- Start Your Django Project in Nginx with uWsgi
Step 0:Install A,B,C,blabla needed This can be seen in my another article in the blog.click here(una ...