使用mismatch函数发生严重的内存泄漏,请指教

zhangjundriver 2008-08-07 06:48:01
#include "stdafx.h"
#include <list>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <functional>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
vector<int> coll1;
list<int> coll2;

for ( int i = 1; i < 6; ++i)
{
coll1.push_back(i);
}
for ( int i = 2; i <= 16; i =+ 2)
{
coll2.push_back(i);
}
// find first mismatch
std::pair<vector<int>::iterator, list<int>::iterator> values;
values = mismatch(coll1.begin(),coll1.end(), // first range
coll2.begin()); // second range

if (values.first == coll1.end())
{
cout << "no mismatch!" << endl;
}
else
{
cout << "first mismatch:"
<< *values.first << "and"
<< *values.second << endl;
}
return 0;
}

...全文
97 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangjundriver 2008-08-07
  • 打赏
  • 举报
回复
我是在VISUAL c++ 9.0下面来编译运行的.就出现内存一直增长的情况
资深码农多年 2008-08-07
  • 打赏
  • 举报
回复
很奇怪,我在gcc下,没有发现异常啊,很正常啊。
jay的Fans 2008-08-07
  • 打赏
  • 举报
回复
for ( int i = 2; i <= 16; i += 2)//改下撒
{
coll2.push_back(i);
}

64,646

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧