map 遍历删除一个元素的时候:正确方法
std::map<int, std::string> c = { {1, "one"}, {2, "two"}, {3, "three"},
{4, "four"}, {5, "five"}, {6, "six"} };
for (auto it = c.begin(); it != c.end(); )
{
if (it->first % 2 == 1)
{
it = c.erase(it);// 返回的是下一个元素的迭代器
}
else
{
it++;
}
}