|
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