find in vector pair c++ code example
Example 1: search in vector of pairs c++
auto it = std::find_if( sortList.begin(), sortList.end(),
[&User](const std::pair<std::string, int>& element){ return element.first == User.name;} );
Example 2: search in vector of pairs c++
bool isEqual(const std::pair<std::string, int>& element)
{
return element.first == User.name;
}
it = std::find_if( sortList.begin(), sortList.end(), isEqual );