Boost logo

Boost :

Subject: Re: [boost] A PP trick to define a synchronized block java-like macro
From: John Bytheway (jbytheway+boost_at_[hidden])
Date: 2009-01-20 18:18:43


JOAQUIN M. LOPEZ MUÑOZ wrote:
> ________________________________________
> De: boost-bounces_at_[hidden] [boost-bounces_at_[hidden]] En nombre de Sebastian Redl [sebastian.redl_at_[hidden]]
> Enviado el: martes, 20 de enero de 2009 22:39
> Para: boost_at_[hidden]
> Asunto: Re: [boost] A PP trick to define a synchronized block java-like macro
>
>> vicente.botet wrote:
>>> for (VARS DECLARATION, bool __continue=true;
>>> __continue;
>>> __continue=false)
>>>
>>>
>> I'm afraid this is not valid syntax. The first clause of the
>> for-statement is a for-init-statement, which can be either an expression
>> with a semicolon, or a simple-declaration. A simple-declaration lets you
>> declare any number of variables, but they must all have the same
>> declspec, i.e. the same fundamental type (with variations like "pointer
>> to", "array of" or "function returning").
>
> The following variation would do:
>
> for (VARS DECLARATION, *continue_hlp_,**continue_=&continue_hlp_;
> continue_;
> continue_=0)

Or you could do:

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


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