2015-09-08 95 views
-1
// 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)’ 

我缺少什麼?

+0

'this-> m_values.end' – Blacktempel

回答

3

您忘記了第二個參數的大括號。

this->m_values.end() 

此外,你可能想調整你的lambda有點。您搜索一個值,不需要複製每個矢量。

[&name](const std::pair<std::string, INIValue> &v)->bool { return v.first == name;} 
+2

* facepalm *我不能相信我錯過了,謝謝。我一直試圖弄清楚爲什麼類型不匹配。 – Fred

+1

也沒有必要複製名稱? – billz

+0

好點的比爾茲,我更多的是試圖讓這個該死的東西編譯。 – Fred

相關問題