我在一篇文章中找到了如何使用迭代器从容器中删除元素的方法。在迭代过程中:
for(auto it = translationEvents.begin(); it != translationEvents.end();)
{
auto next = it;
++next; // get the next element
it->second(this); // process (and maybe delete) the current element
it = next; // skip to the next element
}
为什么在 auto next = it;
中,auto
不需要类型?
我使用的是VS10,不是C++11!