I prefer to use forif increments are unconditionally executed:
for(; it1 != l1.end() && it2 != l2.end(); ++it1, ++it2)
{
//run some code
}
You can omit one test, while the size of the lists is the same, but I'm not sure what happens in the execution of some code!
source
share