
"Pavel Vozenilek" <pavel_vozenilek@hotmail.com> wrote in message news:d4lq0a$is1$1@sea.gmane.org...
"Gennadiy Rozental" wrote:
The formal review of Eric Nibbler's FOREACH macro starts
http://boost-sandbox.sourceforge.net/vault/index.php?directory=eric_niebler foreach.zip
I use FOREACH and like it. It should be part of Boost.
The only time when I needed to fall back on old for(;;) was when I wanted to know whether I am within first/last loop cycle, like in:
for (int i = 0; i < n; ++i) { if (i == 0) cout << "["; ... if (i + 1 == n) cout << "]"; }
Yeah. From time to time (but quite consistently) I also need first/last variable inside loop. You could use FOREACH with first: bool first = true; BOOST_FOREACH(... ) { if( first ) { .... first = false; } } I guess macro could provide this automatically, but I am not sure this convenience warrant an overhead for those who do not need it. Gennadiy