我目前正在使用 pugi xml,我经常使用这样的循环:
for (pugi::xml_node sth: root.child("name").children())
{
//do something
}
然后在某个时候,我意识到我需要在哪个迭代中保存信息,我找到了一些价值,因为稍后会在这个循环之外需要它。我可以在不添加计数器的情况下判断我正在进行的迭代吗?
此外,如果该对象是这样的向量:
std::vector<type> vtr;
for (std::vector<type>::iterator it = vtr.begin(); it != vtr.end(); ++it)
{
//which iteration?
}