|
Boost : |
From: Sean Kelly (sean_at_[hidden])
Date: 2004-01-26 16:08:04
On Mon, 26 Jan 2004, Daryle Walker wrote:
>
> 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.
> >
> > 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.
It looks like we're moving towards a shared_ptr type design for this lock
object. But the simple cases still work:
if( lock l = guard )
or:
if( lock l = lock(guard,t))
or better yet:
if( lock const& l = lock(guard,t))
Sean
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk