Boost logo

Boost :

From: Joe Swatosh (joe-swatosh_at_[hidden])
Date: 2002-06-20 16:52:17


> -----Original Message-----
> From: Fredrik Blomqvist [mailto:f_blq_at_[hidden]]
>
> Another vote for a boost::scope_guard from me.
> I seemed to have missed this thread previously, I also
> had the idea of proposing a boostified-version
> actually!
> I've been using Alexandrescus impl. for some time now
> and I really like it. I found myself mostly using the
> ON_BLOCK_EXIT version though (which didn't seem to be
> included in this proposal (?))

I've uploaded a new version and added the BOOST_ON_BLOCK_EXIT macro. (Is there a way to get the BOOST_JOIN macro without including all of config.hpp?)

> The version below looks really clean and IMO would fit
> into a util-slot.

Thanks.

> Btw the proposed version doesn't include the
> Janitor-complement class, that would be nice to I
> guess.

I've never needed the Janitor class, so didn't include it. If you've needed it, let's put it in.

In a private e-mail Andrei expressed regret about the catch(...) in the destructor. I've added an "exception action" argument to be invoked when the users function throws. By default it swallows the exception (as ScopeGuard), but it can easily be configured to propagate the exception. In the tests is also an example of translating an exception.

-Joe Swatosh

article: http://www.cuj.com/experts/1812/alexandr.htm?topic=experts
test: http://groups.yahoo.com/group/boost/files/scope_guard/scope_guard_test.cpp
code: http://groups.yahoo.com/group/boost/files/scope_guard/scope_guard.hpp


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