You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was found while moving to c++20 by an anonymous internal contributor.
Integrating the finding to mainline, and was already fixed upstream by @rnk (dd870f6929ee)
std::unique iterates on elements of the container, and removes all but
the first element matching the predicate, but does not resize the
container. This means the following code doesn't assert.
```cpp
std::vector<int> v = { 1, 1, 2, 2, 3, 3 };
assert(v.size() == 6);
std::unique(v.begin(), v.end());
assert(v.size() == 6);
```
The function returns a past-end iterator, and all the undefined elements
are at the end of the container, meaning we can safely erase them, and
fix the container size.
Signed-off-by: Nathan Gauër <[email protected]>
0 commit comments