[Bug libstdc++/106869] ranges::unique does nothing unless ranges::sort called first or something else is wrong.
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Sep 7 11:25:16 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106869
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, that's correct.
std::unique and std::ranges::unique only remove **consecutive** duplicates,
they don't search the entire range again and again for duplicates. So you need
to sort it first, or otherwise arrange for all duplicates to be adjacent to
each other.
https://en.cppreference.com/w/cpp/algorithm/unique
More information about the Gcc-bugs
mailing list