Boost logo

Boost :

Subject: Re: [boost] [scope_exit] Boost.ScopeExit capturing 'this'
From: Kim Barrett (kab.conundrums_at_[hidden])
Date: 2009-03-10 19:34:52

At 8:35 AM +0000 3/10/09, adam.butcher_at_[hidden] wrote:
>The enhancement allows capturing of 'this' in the BOOST_SCOPE_EXIT
>capture sequence allowing access to any class members within the body.

FWIW I ran into this problem almost immediate upon starting to use
BOOST_SCOPE_EXIT, and it seems to be a common situation in my usage.

>Member access for the enclosing class can be performed with the
> (*this) -- convertible to enclosing 'this'
> (**this) -- enclosing 'this'
> (*this)->member -- accesses member 'member' of enclosing 'this'
>This syntax is perhaps controversial though I think both Alex and
>myself are reasonably happy with it. Alternatives suggested were
>'this_', 'this_()', 'enclosing_this', 'enclosing_this()', 'enclosing',
>'enclosing()', 'self' and 'self()'.

Any access syntax that doesn't have the form of a variable name will
go right back to the original problem if one has a scope exit in the
body of another scope exit. I've not yet needed to do something like
that with BOOST_SCOPE_EXIT, but I know that I've more than once
written a try/finally block that was in the finally clause of another
try/finally block (in other languages, obviously).

Boost list run by bdawes at, gregod at, cpdaniel at, john at