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: Ryan (mccorywork_at_[hidden])
Date: 2009-09-24 21:09:01


On Thu, Sep 24, 2009 at 11:38 AM, Anthony Foglia <AFoglia_at_[hidden]>wrote:

> Or, even easier, make the key just the string and the value a pair of the
> int and the vector of classA:
>

On Thu, Sep 24, 2009 at 12:01 PM, Nat Goodspeed <nat_at_[hidden]> wrote:

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

This would indeed make the insert easier at the cost of complicating the
retrieval. By making the int part of the key the retrieval is trival

m_VariableDestinations.find(std::make_pair(name, intValue));

If I was to move the int out of the pair I found that it increased the
difficulty quite a bit.

On Thu, Sep 24, 2009 at 11:38 AM, Anthony Foglia <AFoglia_at_[hidden]>wrote:

> He can pass a custom less functor class as the third template parameter to
> the map. Something like:
>

Is the advantave of using the custom functor over the lambda class the
ability to use the insert function correctly? By using the functor the
insert, that Nat recommended, would indeed only compare the name value and
correctly return true or false regardless of the second parameter. Is this
correct?

Ryan



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