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 McConnehey (mccorywork_at_[hidden])
Date: 2009-09-24 12:11:57


> std::pair<cMap::iterator, bool> inserted =
> myMap.insert(cMap::value_type(cMap::key_type(givenName, properInt),
> cmap::mapped_type()));
> if (! inserted.second) // oh, it already existed?
> {
> ...
> }

Since I'm using both givenName and properInt as a key, the insert will
never return false for just a duplicate of givenName. Also, if the
insert did return false then it means a good value at that map key has
been replaced. The reason I'm trying to catch this duplication is
because "last value entered wins" doesn't meet the requirement I was given.

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