-----Original Message----- From: Duane Murphy [mailto:duanemurphy@mac.com] Sent: Friday, August 09, 2002 3:23 PM To: Boost Users Subject: Re: [Boost-Users] Getting the hang of Boost::Bind
--- At Fri, 9 Aug 2002 15:08:06 -0700, Tom Matelich wrote:
I have a vector of
class Landmark { public: std::string const& getName() const; ... };
I want to do a find_if for a name that I have.
something like std::find_if(begin, end, boost::bind(std::equalstd::string(???, name_to_find)));
What do I put for the ??? ?
Nothing. Your done. :-) bind takes a pointer to a function (among other things) as the first parameter. It then calls that function with the parameters you specify. You use _1, etc for parameters that are input to bind. In your case:
std::find_if(begin, end, boost::bind(std::equalstd::string, name_to_find, _1)));
But I have to compare name_to_find to the result of _1.getName() don't I? ----------------------------------------------------------------------- DISCLAIMER: Information contained in this message and/or attachment(s) may contain confidential information of Zetec, Inc. If you have received this transmission in error, please notify the sender by return email. -----------------------------------------------------------------------