Boost logo

Boost Users :

From: Olaf van der Spek (olafvdspek_at_[hidden])
Date: 2007-08-08 12:19:20


On 8/8/07, Cory Nelson <phrosty_at_[hidden]> wrote:
> On 8/8/07, Olaf van der Spek <olafvdspek_at_[hidden]> wrote:
> > Hi,
> >
> > I'm trying to sort a map based on second, but I get all kinds of
> > compiler errors and I have no idea what's wrong. A simple _1 > _2
> > works fine, but that compares the maps themselves.
> >
> > Also, is there a better way to write the copy from map to vector or to
> > sort the map in general?
>
> maps are already sorted! see the third template argument. a simple

Yes, on key, not on value.

> vec.insert(vec.end(), map.begin(), map.end()) will copy it. did you
> need something else?

Yes, I use iterators (or pointers) in the vector to avoid an expensive
copy in the case of strings.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net