Boost logo

Boost :

From: Powell, Gary (powellg_at_[hidden])
Date: 2003-10-09 17:19:34


Eric wrote:
Resending. Based on the number of private replies I got, I suspect there
is some interest in adding a foreach looping construct to Boost. The
lack of public discussion makes me wonder, though. Does no one want to
publically support an Ugly Macro? :-) Or is this just not compelling enough?

To recap, I'm suggesting the addition of BOOST_FOREACH to make it
trivial to write loops over sequences and containers of various sorts.

Typical usage:
std::list<int> int_list;
...
BOOST_FOREACH( int &i, int_list )
{
      // mutates the int in the list:
      i += 20;
      // break works as you would expect
      if ( i == 100 )
          break;
}
----------------------------------------------------
I'm sorry but Yuck.

*) Macros have a nasty and well known scoping problem.

*) "for(;;){}" works really well for this case.

     -Gary-

powellg_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk