Boost logo

Boost Users :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-08-10 07:46:16


On Friday 09 August 2002 06:40 pm, Tom Matelich wrote:
> std::vector<Landmark> v;
> ...
> std::vector<Landmark>::const_iterator iter =
> std::find_if(v.begin(), v.end(),
> boost::bind(std::equal<std::string>,
> boost::bind(ZLandmark::Landmark::getName, _1),
> name_to_find));

> Oh, and I guess that should be std::equal_to, right? Didn't work either
> though.

I'm not sure what the error message is, but to clean up the errors I see:

std::vector<Landmark>::const_iterator iter =
   std::find_if(v.begin(), v.end(),
                boost::bind<bool>(std::equal_to<std::string>(),
                                    boost::bind(&Landmark::getName, _1),
                                    name_to_find));

Mostly just syntactic cleanups, but the boost::bind<bool> part is important.
It's required because of some MSVC quirks, and basically tells bind that the
return type for the function object will be 'bool'. Otherwise, bind would try
to figure out the return type on its own, and I think that requires partial
specialization (not supported on current versions of MSVC).

        Doug


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