I would like to erase all the items less than v in C++11 standard container set, here is my code:
void delete_less_than(set<int> & ss, int const v) { for (auto item: ss) { if (item < v) { ss.erase(ss.find(item)); } else break; } } Will the code work properly? I seems okay on my computer (g++ 4.7.3), but loops infinitely on some online judge where I submit my code.