65,208
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <iostream>
#include <list>
#include <functional>
#include <algorithm>
using namespace std;
struct ISOMSG
{
int idx;
int content;
ISOMSG()
{
}
ISOMSG(int nIdx)
{
idx = nIdx;
content = 0;
}
ISOMSG(int nIdx, const int &nContent)
{
idx = nIdx;
content = nContent;
}
};
int main(int argc, char* argv[])
{
list<ISOMSG> m_msg;
ISOMSG tmp_msg;
for (int i = 0; i < 15; i++)
{
memset(&tmp_msg, 0, sizeof(ISOMSG));
tmp_msg.idx = i;
tmp_msg.content = i+3;
m_msg.push_back(tmp_msg);
}
// 下面这条语句编译有问题的
list<ISOMSG>::const_iterator it = find_if(m_msg.begin(), m_msg.end(), bind2nd(equal_to<ISOMSG>(), 10));
if (it != m_msg.end())
{
cout<<it->content<<endl;
}
return 0;
}