Boost logo

Boost Users :

Subject: Re: [Boost-users] foreach question
From: Neal Becker (ndbecker2_at_[hidden])
Date: 2010-10-17 19:59:25


Jerry Jeremiah wrote:

> Pete Bartlett <pete <at> pcbartlett.com> writes:
>
>>
>> See this thread http://thread.gmane.org/gmane.comp.lib.boost.user/54162
>> And the resulting Trac ticket:
>> https://svn.boost.org/trac/boost/ticket/3469
>>
>> for a essentially negative answer.
>>
>
> Personally, I like the answer in that thread that said:
>
> #define INDEX_FOREACH(index,a,b) \
> for(unsigned int index = static_cast<unsigned int>(-1); \
> index == static_cast<unsigned int>(-1);) \
> BOOST_FOREACH(a,b) if(++index,true)
>
> The for loop just does a variable declaration in a way that means you
> won't get bit by using it somewhere that doesn't allow variable
> declarations. Convoluted but important.
>
> Of course, it isn't that generic - it always assumes you want an int
> index. But then that is what the question said...
>
> Jerry

Won't win any beauty contest.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net