由于csdn太辣鸡, 只贴练习代码做记录,不再写注释分享
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
static std::map<int, std::string> mapTest = {
{1,"hello"},{2,"world"},{3,"hello"},{5,"world"},{4,"world"}
};
int main()
{
auto it = std::find_if(mapTest.begin(), mapTest.end(), [&](const std::map<int, std::string>::value_type& pair) {
return pair.second == "world";
});
while (it != mapTest.end())
{
std::cout << it->first << std::endl;
it = std::find_if(++it, mapTest.end(), [&](const std::map<int, std::string>::value_type& pair) {
return pair.second == "world";
});
}
}