On Fri, Nov 11, 2005 at 12:25:50AM +0100, Lars Gullik Bjønnes wrote: > | + ParagraphList::const_iterator it = pars_.begin(); > | + ParagraphList::const_iterator const end = pars_.end(); > | + while (it != end && &(*it) != &par) > | + ++it; > | + > > for (; it != end; ++it) > if (&(*it) == &par) > break; > > should not generate any worse code.. and follows the for(...) idom. > > but I would prefere > > ParagraphList::const_iterator it = > find_if(pars_.begin(), pars_.end(), some_functor(par));
Why? It's obviously more code to type, to read, and not simpler to understand. You obviously could write out the for loop but cut the corner in the some_functor case. [Thing would obviously different with lambda...] > | Of course, profiling would be interesting too :) > > Clearity wins. IMO the for loop is much clearer... Andre'