|
Boost : |
From: Daryle Walker (darylew_at_[hidden])
Date: 2004-01-26 15:12:31
On 1/25/04 5:28 PM, "Matthew Hurd" <matt_at_[hidden]> wrote:
[SNIP]
> But it does look neat.
>
> if (lock lk(guard_,t))
>
> and would release automagically as the if scope rolls out. I'm warming to
> it.
>
> Other than that you could scope it as I wrote previously:
>
> {
> lock smock(guard_, false);
> if (smock.acquire_timed(t)) {
> // don't worry be happy
> }
> }
>
> I thought a comma operator could rescue us, but I was misguided:
>
> if (lock lk(guard_,false), lk.acquire_timed(t) )
>
> would do the trick if it was valid c++, but I'm pretty sure it isn't.
You're right, you CANNOT do:
if ( Type Object1( XXX ) ) // possibly with ", Object2( YYY )", etc.
You can only do
if ( Type Object = Whatever )
or the "scoping in advance" trick you already showed.
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk