I have an std::list<BallPair> list, where BallPair is a custom class that overloads operator==. In the list there are duplicate values, which I want to remove. I tried the following:
Code:
typedef std::list<BallPair>::iterator BallPairListItor;
Code:
for(BallPairListItor i = l.begin(); i != l.end(); ++i)
for(BallPairListItor j = l.begin() + 1; j != l.end() - 1; ++j)
if(*i == *j)
j = l.erase(j);
but unfortunately list iterators do not provide operator + or operator -.
I also tried list::unique but at unique - C++ Reference says:
Notice that an element is only removed from the list if it is equal to the element immediately preceding it.
Any ideas?