This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: STL list error


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]