From: Eric Niebler (eric_at_[hidden])
Date: 2005-05-03 13:33:13
Dave Harris wrote:
> In-Reply-To: <42778635.20706_at_[hidden]>
> eric_at_[hidden] (Eric Niebler) wrote (abridged):
>>* This isn't an algorithm, so I don't want to evoke std::for_each.
> What is it that makes std::for_each an algorithm and BOOST_FOREACH not? To
> me they seem to be doing similar jobs, albeit in different ways.
Is do/while an algorithm? You probably don't think of it that way. It's
certainly not an algorithm in the STL sense like std::for_each is. The
most effective way to think of BOOST_FOREACH (in my experience) is as a
new looping construct -- a foreach keyword.
To encourage people to think of it as an algorithm in the STL sense
would be a mistake. It is range-based, not iterator-based. You can break
and continue and return from the loop body. You can't do any of those
things from an STL algorithm.
-- Eric Niebler Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk