cpp iterator
for (auto it = copy_nodes2[d_idx2].adj.begin(); it != copy_nodes2[d_idx2].adj.end(); ++it)
{
if (*it == s2.name)
{
copy_nodes2[d_idx2].adj.erase(it);
#ifdef DEBUG_getNei_ignore
cout << "copy2: remove " << ignore_node2.name << "->" << *it
<< "(" << s2.name << ")"<< ": ";
#endif
break;
}
}
if条件是*it == s2.name
,在#ifdef DEBUG
里输出,*it
和s2.name
不一样:
copy2: remove 8->10(10):
是不是外层for循环里的++it
在#ifdef
之前执行了?