Boost logo

Boost Users :

From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2002-08-09 17:23:21


--- 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::equal<std::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::equal<std::string>,
name_to_find, _1)));

 ...Duane

-- 
"If tyranny and oppression come to this land, it will be in the
guise of fighting a foreign enemy."              - James Madison

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