On Wed, Feb 11, 2009 at 12:06 PM, Peter Barker
Hi,
I just wondered if there was already an algorithm (or way to compose one) in Boost that would allow me to iterate over a container of pointers to objects calling a function on each one and completing when one of them returned a particular value?
For example, I have a master/child relationship and the master has a method called shouldCalculate(). Whether this returns true is partly dependent on what the children return for their shouldCalculate() method. So I'd like to say something like this:
bool Master::shouldCalculate() { // Look at data at the master level to see if it's stale. If it is, return true.
// See if any of the children should calculate bool staleChildren = boost::for_each_until(children_.begin(),children_.end(),
boost::bind(&Child::shouldCalculate,_1),until_true_returned);
return staleChildren; }
Regards,
Pete
Sorry for the noise. Just figured std::find_if() should do it. Regards, Pete