dimanche 16 juin 2019

Iterating ranged-based for loop from end to begin [duplicate]

This question already has an answer here:

Reverse iteration from last item to first item can be done like this:

for (int i = myContainer.size() - 1; i >= 0; --i) {
    // Do
}

How can I reverse a ranged-based for loop:

for (auto i : myContainer) {
    // Do
}

Aucun commentaire:

Enregistrer un commentaire