|
Boost Users : |
From: Marshall Clow (marshall_at_[hidden])
Date: 2008-07-27 02:31:05
At 12:00 AM -0500 7/27/08, Meryl Silverburgh wrote:
>Hi,
>
>Can you please tell me if there is an easy way to replace the
>following for loop using boost:lambda?
>
>I have a vector of A, i want to call 'aMethod of each A, and stop it
>when one of them return true.
>
> for (vector<A*>::const_iterator iter = aList.begin() ; iter !=
>aList.end(); ++iter) {
>
> A* anA = (*iter);
>
>// break out the for loop if aMethod return true;
> if (anA->aMethod()){
> break;
> }
Isn't this what std::find_if does?
std::find_if ( aList.begin (), aList.end (); bind ( A::Method, *_1 ));
[ Code not compiled, just composed in email client, but you get the idea ]
<http://www.boost.org/doc/libs/1_35_0/doc/html/lambda/le_in_details.html#member_functions_as_targets>
-- -- Marshall Marshall Clow Idio Software <mailto:marshall_at_[hidden]> It is by caffeine alone I set my mind in motion. It is by the beans of Java that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning. It is by caffeine alone I set my mind in motion.
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