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所指向的元素,返回一个指向被删元素 ...
随机推荐
- Linux 查看系统硬件信息(实例详解)
原文链接:http://www.cnblogs.com/ggjucheng/archive/2013/01/14/2859613.html linux查看系统的硬件信息,并不像windows那么直观, ...
- 自定义图文混排视图MyImageTextView
http://blog.csdn.net/xujunfeng000/article/details/36399339?utm_source=tuicool&utm_medium=referra ...
- 【HOJ1356】【Miller_rabin素性测试】Prime Judge
Given a positive integer, your job is writing a program to determine whether it is a prime number or ...
- mysqldump: command not found问题解决
首先得知道mysql命令或mysqldump命令的完整路径,可以使用find命令查找除非你知道mysql安装路径可以略过这一步. find / -name mysql -print 例如我的mysql ...
- javascript常用内置对象总结(重要)
Javascript对象总结 JS中内置了17个对象,常用的是Array对象.Date对象.正则表达式对象.string对象.Global对象 Array对象中常用方法: Concat():表示把几个 ...
- 面试后 follow up letter 分享
分享一下最近面试外企的follow up letter. Dear Mr. Xu, Thank you again for the time you and Mr. Guo spent wit ...
- 汇总前端最最常用的JS代码片段
html5选择器 //参数均接收一个合法的css选择器 element = document.querySelector('.foo,.bar');//返回带有foo或者bar样式类的首个元素 ele ...
- Android Framework------之Keyguard 简单分析
前面对于MediaPlayer的系统研究,刚刚开始,由于其他原因现在要先暂停一下.这次要看的模块是android 4.2 系统中的Keyguard模块.在接触之后才发现,android4.2的keyg ...
- python之加密
import hashlib obj = hashlib.md5(bytes('adfasfasdfsfasf',encoding = 'utf-8')) obj.update(bytes('123' ...
- 嵌套JSON 取出name与value
好久不用都忘了 mark下 $.each( { name: "John", lang: "JS" }, function(i, n){ alert( &qu ...