Boost logo

Boost Users :

Subject: Re: [Boost-users] [lambda] Defining a predicate for std::find_if if the key to a std::map is std::pair
From: Nat Goodspeed (nat_at_[hidden])
Date: 2009-09-24 15:01:17


Anthony Foglia wrote:

> Nat Goodspeed wrote:

>> Forgive me if this is a stupid question, but if you don't want to
>> compare the int, why is it part of the key at all?

> He wants to compare the int upon retrieval, but it doesn't matter for
> insertion. But I think he'd be better off getting the map to only care
> about the string.
>
> Or, even easier, make the key just the string and the value a pair of
> the int and the vector of classA:
>
> typedef map<string, pair<int, vector<classA> > cMap;

Yes, that's what I was thinking: migrate the int from the key to the
mapped_type.


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