|
Boost Users : |
Subject: Re: [Boost-users] Problem with boost::bind, boost::shared_ptr and std::find_if algorithm
From: Nathan Crookston (nathan.crookston_at_[hidden])
Date: 2010-08-03 11:48:17
Hi Przemyslaw,
On Tue, Aug 3, 2010 at 7:34 AM, <przemyslaw.sliwa_at_[hidden]> wrote:
>
> All,
<snip code>
> Since this looks really ugly I would like to ask you how this can be
> converto to find_if algorithm with a little help of boost::bind. I tried but
> could not succees.
It seemed necessary to add a nested bind call.
#include "boost/bind.hpp"
#include "boost/shared_ptr.hpp"
#include <map>
struct WTH
{
int cut;
};
int main()
{
int cut;
typedef std::multimap<int, boost::shared_ptr<WTH> > DataMap;
std::find_if(myMap.begin(), myMap.end(),
boost::bind(&WTH::cut,
boost::bind(&DataMap::value_type::second, _1)) == cut);
return 0;
}
HTH,
Nate
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