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]

STL list error



> Hi There,
> 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.
> 
> int main( void )
> {
>     list< int > myList;
> 
>     myList.push_back( 10 );
>     myList.push_back( 10 );
>     myList.push_back( 20 );
>     myList.push_back( 30 );
>     myList.push_back( 40 );
> 
>     cout << "Size of list = " << myList.size() << endl;
>     myList.unique();
>     cout << "Size of list = " << myList.size() << endl;
>     myList.push_back( 20 );
>     myList.unique();
>     cout << "Size of list = " << myList.size() << endl;
> 
> }
> 
> Regards
> Wilson
> 

-- 
Orion Montoya, FSF Office Staff
Free Software Foundation     |  Phone: +1-617-542-5942
59 Temple Place, Suite 330   |  Fax:   +1-617-542-2652
Boston, MA 02111-1307  USA   |  Web:   http://www.gnu.org



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