lundi 25 avril 2016

Choosing a for loop based on if condition

Condition based for loop selection.

if(valid)
for (std::multimap<int,int>::reverse_iterator rit=id_count.rbegin(); mcount<10 && rit!=id_count.rend();++rit)
else
for (std::multimap<int,int>::iterator rit=id_match.begin(); mcount<10 && rit!=id_match.end();++rit)

{
    //this is common for both for loop
}

how to achieve this in C++?

Aucun commentaire:

Enregistrer un commentaire