Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3029

Erase an stl element within the or loop

$
0
0
Hello

I have the ollowing for loops, inside the second for loop, i want to erase the second element based on some condition.
I know erasure invalidates the iterator. What is the nice way to do this ?

Code:

        for (auto& sulCell : nCellList.sulCellList)
        {
                        bool bFirstMatch = false;

                        for (auto& tddCell : nCellList.tddCellList)
                        {
                              if(condition)
                              erase(tddCell);
                          }
      }


Viewing all articles
Browse latest Browse all 3029

Latest Images

Trending Articles



Latest Images