g++中使用std map根据value查找find_if

来源:互联网 发布:大数据开发工程师招聘 编辑:程序博客网 时间:2024/06/08 05:59

error: no matching function for call to 'ptr_fun(<unresolved overloaded function type>)'


#include <algorithm>
#include <functional>

这两个是必须的



bool equal(std::pair<char*,devNode*> data,char* ip0)
{
 if(strcmp(data.second->ip,ip0) == 0)
 {
  return true;
 }else
 {
  return false;
 }
}

 map<char*,devNode*>::iterator iter_find;

iter_find = std::find_if(m_devListPreIns.begin(),m_devListPreIns.end(),std::bind2nd(std::ptr_fun(::equal),szip));


关键时候到了,哈哈,上面定义的equal函数前面的两个::是必须的,否则就会报告

 map<char*,devNode*>::iterator iter_find;

原创粉丝点击