In std::multiset is there a function or algorithm to erase just one sample (unicate or duplicate) if an element is found
问题 Perhaps this is a duplicate but I did not find anything searching: When erase(value) is called on std::multiset all elements with the value found are deleted. The only solution I could think of is: std::multiset<int>::iterator hit(mySet.find(5)); if (hit!= mySet.end()) mySet.erase(hit); This is ok but I thought there might be better. Any Ideas ? 回答1: auto itr = my_multiset.find(value); if(itr!=my_multiset.end()){ my_multiset.erase(itr); } I would imagine there is a cleaner way of