Is this a bug or lack of understanding?

Stephen Webb stephen@bregmasoft.com
Tue Apr 18 06:18:00 GMT 2000


On Tue, 18 Apr 2000, Chris Picton wrote:
> Stephen Webb wrote:
> 
> > On Tue, 18 Apr 2000, Chris Picton wrote:
> > > Hi
> > >
> > > I have the following program:
> > >...
> >
> > Your first version of the program maps strips to ints.  The second maps the length of the strings to ints.  A map<>
> > will hold only one instance per value, so I would expect only one entry per length of string in the second version of
> > the program.
> 
> In both of them, I declare map<string, int, s>
> 
> Dowsnt that mean I am mapping strings to ints in both cases.  Shouldnt the sorting function be only to decide in what
> order to store the objects.

No.  

In both cases you're pairing a string and an int.  In the first case you're mapping the lexicographic order of the
strings to the order of the ints.  In the second case you're mapping the length of the strings to the order of the
ints.

Stephen M. Webb
Principle Consultant, Bregmasoft


More information about the Libstdc++ mailing list