I have a set in C++. I want to delete all the elements from the set which are less than a specified value. E.g.
std::set setElem;
setElem.insert(1);
setElem.insert(45);
setElem.insert(47);
//setElem contains {1,45,47}
//delete all elements less than 46 such that the set now becomes: {47}
I know we can iterate over the set and delete the elements by verifying whether they are less than 46 or not. Is there some other more efficient way in C++ to do the same.
gcc version which I am using is: gcc (Ubuntu/Linaro 4.6.4-6ubuntu2) 4.6.4