Boost logo

Boost Users :

Subject: Re: [Boost-users] using bind with find_if
From: Igor R (boost.lists_at_[hidden])
Date: 2011-03-09 15:30:44


> I am currently using find_if with bind2nd to perform a search on a vector.
> My current code looks like this:
>
>
> struct OverrideMatches : public std::binary_function<const TItemOverride,
> const TItemOverride, bool>
> {
>   bool operator()( const TItemOverride& OverrideSource, TItemOverride
> OverrideTarget ) const
>   {
>      return OverrideSource.ChildAssyItemRecNo ==
> OverrideTarget.ChildAssyItemRecNo &&
>             OverrideSource.LinkItemRecNo == OverrideTarget.LinkItemRecNo;
>   }
> };
>
> TItemOverrideGateway::Container_t::iterator where =
>  std::find_if( FOverridesContainer.begin(),
>                FOverridesContainer.end(),
>                std::bind2nd( OverrideMatches(),
>                TItemOverride( "", 0, "", 0, ChildItemRecNo,
> LinkItemRecNo ) ) );

Excuse my ignorance, but if you just want to find elements equal to
some specific element, why don't you use simply std::find() -- without
binds etc.?


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