Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

the wrong way

for(auto it=l.cbegin(); it!=l.cend(); ++it){
    for(auto jt=++it; jt!=l.cend(); ++jt){
        cout << *it << " <-> " << *jt << endl;
    }
}

it is increased again in the inner loop!!!

the correct way

for(auto it=l.cbegin(); it!=l.cend(); ++it){
    for(auto jt=next(it); jt!=l.cend(); ++jt){
        cout << *it << " <-> " << *jt << endl;
    }
}

it is very tricky to iterate a container and delete elements blog about it