求教vs2005下的lower_bound使用

danxiaodemao 2009-05-21 02:31:14
代码如下,主要是调用lower_bound哪行出的错

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct Element{
int i;
};

bool IsLess(const Element& i, const Element& j)
{
return i.i < j.i;
}

bool IsLittle(const Element i, int * j)
{
return i.i < *j;
}

int main()
{
vector<Element> v;
int i = 0;
Element e;
for (i=10; i>0; --i)
{
e.i = i;
v.push_back(e);
}
sort(a.begin(), a.end(), IsLess);
vector<Element>::iterator it;
int j = 4;
it = lower_bound(a.begin(), a.end(), &j, IsLittle);
cout << (*it).i << endl;
return 0;
}


问题出现在lower_bound函数上,在dev下编译运行没有问题。但是在vs2005下,总提示c:\program files\microsoft visual studio 8\vc\include\xutility(314) : error C2664: “bool (const Element &,int *)”: 不能将参数 2 从“Element”转换为“int *”

在release下编译运行都没问题,但问题是我在其它地方用到了lower_bound,而且我想看一下那个程序运行过程的一些中间结果,每次都cout肯定不现实,但是只要用lower_bound就无法debug,求高人指点如何解决这个问题。
...全文
26 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
http://blog.csdn.net/J_Factory/archive/2008/10/01/3007886.aspx
liliangbao 2009-05-21
  • 打赏
  • 举报
回复
帮顶!!!

64,648

社区成员

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

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