-
Notifications
You must be signed in to change notification settings - Fork 804
Description
The specification for forward_list::unique says:
Erases all but the first element from every consecutive group of equal elements referred to by the iterator
iin the range[first + 1, last)for which*i == *(i-1)(for the version with no arguments) orpred(*i, *(i - 1))(for the version with a predicate argument) holds.
Err, what?
Given {1, 1, 1, 1, 1, 2, 2, 2, 2, 2}, we:
- consider the range
[first + 1, last):{1, 1, 1, 1, 2, 2, 2, 2, 2}. - identify the elements for which
*i == *(i-1), dropping the first2. - identify the consecutive groups of equal elements from step (2):
{1, 1, 1, 1}and{2, 2, 2, 2}. - erase all but the first element from each such group.
The result is {1, 1, 2, 2}. That doesn't seem right.
The problem here is that we express basically every part of the rules twice or three times in the same sentence, and usually at least all but one of those repetitions is wrong. (Eg, compare "equal" to the more careful description later, compare "all but the first" with the use of [first + 1, last) and *i == *(i-1).)
Perhaps we meant:
Erases all but the first element from every consecutive group of equal elements. That is, for a nonempty list, erases all elements referred to by the iterator
iin the range[first + 1, last)for which*i == *(i-1)(for the version with no arguments) orpred(*i, *(i - 1))(for the version with a predicate argument) holds.
Oh, and while we're here: what are first and last supposed to be here? I think it means begin() and end()...