STL list error
Rupert Wood
me@rupey.net
Mon Oct 22 02:37:00 GMT 2001
Wilson wrote:
> Check the following sample code. Here I expect the second unique()
> call to the list should make the list unique after the addition of
> 20 again. But its not happening. Can you provide the reason for
> this.
C++ standard 23.2.2.4:
| 19. Effects: Eliminates all but the first element from every
| consecutive group of equal elements ...
i.e. unique() only considers uniqueness vs. adjacent elements. You need
to 'myList.sort();' first.
Rup.
More information about the Gcc-help
mailing list