Boost Users :
Subject: Re: [Boost-users] Using boost::bind with stl algorithms
From: Lars Viklund (zao_at_[hidden])
Date: 2010-08-23 13:00:32
On Mon, Aug 23, 2010 at 04:49:58PM +0100, przemyslaw.sliwa_at_[hidden] wrote:
> I have the following question. I have two containers
> std::set<std::string> insertedEvents;
> std::vector<std::string> eventNames;
> How I would like to copy all those elements from eventNames which are not
> in insertedEvents. Can this can be done somehow using the boost::bind
<algorithm> contains std::set_difference, which is most probably what you want,
assuming that eventNames is sorted.
If it's not,
boost::bind(&std::set<std::string>::count, boost::cref(insertedEvents), _1)
That is, bind the count member function of std::set to your set of
events, and evaluate that for each element in your range.
Of course, something like Phoenix or Lambda would make the predicate
easier on the eyes.
-- Lars Viklund | zao_at_[hidden]
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