Boost logo

Boost :

Subject: Re: [boost] A PP trick to define a synchronized blockjava-like macro
From: Peter Bartlett (pete_at_[hidden])
Date: 2009-01-21 07:31:56


Quoting "vicente.botet" <vicente.botet_at_[hidden]>:

> ----- Original Message -----
> From: "Peter Bartlett" <pete_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Wednesday, January 21, 2009 9:46 AM
> Subject: Re: [boost] A PP trick to define a synchronized blockjava-like macro
>
>
>>
>> Quoting John Bytheway <jbytheway+boost_at_[hidden]>:
>>
>>> if (bool stop_ = false) {} else
>>> for (VARS DECLARATION; !stop_; stop_ = true)
>>>
>>> which I'd consider more readable (Thanks to BOOST_FOREACH for this trick).
>>>
>>> John Bytheway
>>
>> The other trick in this part of the book is to use nested fors, which
>> can give you slightly more flexibility. FOREACH does this too, IIRC.
>
> Hi,
>
> Thanks John for the if else suggestion. I like it.
> Could some of you point where FOREACH use these tricks?

The main BOOST_FOREACH macro definition (line 1059 in foreach.hpp in
version 1.37) uses four nested ifs. It uses a nested for too - the
last for is the "real" for loop!


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