C++ 我不明白为什么这个不能编译
以下是错误:C++ 我不明白为什么这个不能编译,c++,C++,以下是错误: // m_values is of type std::vector<std::pair<std::string,INIValue> > std::find_if(this->m_values.begin(),this->m_values.end, [name](std::pair<std::string,INIValue> v)->bool { return v.first == name;}); 我遗漏了什么?您忘记了第
// m_values is of type std::vector<std::pair<std::string,INIValue> >
std::find_if(this->m_values.begin(),this->m_values.end, [name](std::pair<std::string,INIValue> v)->bool { return v.first == name;});
我遗漏了什么?您忘记了第二个参数的大括号
error: no matching function for call to ‘find_if(std::vector<std::pair<std::basic_string<char>, INIValue> >::iterator, <unresolved overloaded function type>, INISection::value(const string&)::__lambda0)’
此外,您可能需要稍微调整lambda。您搜索一个值,无需复制每个向量
this->m_values.end()
这个->m_values.endfacepalm我不敢相信我错过了,谢谢。我一直想弄明白为什么类型不匹配。也没必要复制名称?好吧,billz,我只是想把该死的东西编译一下。
[&name](const std::pair<std::string, INIValue> &v)->bool { return v.first == name;}