Linked by Eugenia Loli on Mon 1st Aug 2005 00:05 UTC
General Development Don't be jealous of programmers using new languages, such as Python or C#! C++ gives you many ways to iterate through data you've stored in containers, supports for-each, and has helpful devices called lambda functions. Jeff Cogswell shows you how you can fly through your containers with ease.
Thread beginning with comment 12128
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[2]: BOOST_FOREACH
by falemagn on Mon 1st Aug 2005 16:45 UTC in reply to "RE: BOOST_FOREACH"
falemagn
Member since:
2005-07-06

Looking at the code of BOOST's foreach, I see it has a lot of code before the real for loop, which makes it impossible to use BOOST_FOREACH the same way you would use for(), forcing you to wrap it up between braces, in some circumstances.

It's also true that my implementation has the pitfall that it may evaluate the arguments more than once, though. Well, to solve these issues c++ should let the user define her own keywords... perhaps one day ;)

Reply Parent Score: 1

RE[3]: BOOST_FOREACH
by eric_niebler on Mon 1st Aug 2005 18:32 in reply to "RE[2]: BOOST_FOREACH"
eric_niebler Member since:
2005-06-29

That's not true. BOOST_FOREACH expands to a single statement, so you can use it where ever you could use a regular for loop. No extra braces required.

Reply Parent Score: 1

RE[4]: BOOST_FOREACH
by falemagn on Mon 1st Aug 2005 20:10 in reply to "RE[3]: BOOST_FOREACH"
falemagn Member since:
2005-07-06

I stand corrected, I had missed the if...else statements there, sorry.

As for the iterator type, I stand corrected there too, although that was more akin to a typo than a real mistake ;)

Reply Parent Score: 1