|
Boost Users : |
Subject: Re: [Boost-users] using bind with find_if
From: Dennis Jones (djones_at_[hidden])
Date: 2011-03-09 16:09:34
----- Original Message -----
From: "Igor R" <boost.lists_at_[hidden]>
To: <boost-users_at_[hidden]>
Sent: Wednesday, March 09, 2011 12:30 PM
Subject: Re: [Boost-users] using bind with find_if
>> 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.?
I don't want to find elements equal to a specific element. I want to find
an element that meets specific criteria -- that is, find the element for
which two of its data members have specific values. If I already had all
the criteria for the element, I wouldn't need to find it in the first place!
- Dennis
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