Boost logo

Boost :

Subject: Re: [boost] [scope_exit] D-style scope(failure) and scope(success) in C++
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2013-09-27 03:23:08


On Thu, Sep 26, 2013 at 11:37 PM, Andrey Semashev
<andrey.semashev_at_[hidden]> wrote:
> On Thursday 26 September 2013 16:24:21 Emil Dotchevski wrote:
>> On Thu, Sep 26, 2013 at 4:20 PM, Evgeny Panasyuk
>>
>> <evgeny.panasyuk_at_[hidden]> wrote:
>> > 27.09.2013 3:08, Emil Dotchevski:
>> >> Perhaps I'm missing something, but if it is a facility that aids the
>> >> scope_exit library, it should be part of the scope_exit library. Do
>> >> you feel that it should be part of Boost Exception?
>> >
>> > There are two parts:
>> > 1. function uncaught_exception_count
>> > 2. scope(failure) and scope(success) which are built on top of
>> > uncaught_exception_count
>> >
>> > I have in mind two approaches:
>> > a) Add both into Boost.ScopeExit
>> > or
>> > b) As a first step add uncaught_exception_count into Boost.Exception - as
>> > it is closely related to it's theme. And then
>> > scope(failure)/scope(success) will go into Boost.ScopeExit.
>>
>> Is there a use case for uncaught_exception_count other than to
>> implement D-style scope-exit/-failure?
>
> In Boost.Log, I use it to implement my own guard objects which must perform
> some finalizing work at destructor. With uncaught_exception_count I am able to
> detect whether the destructor is invoked as a result of an exception and
> cancel the work.

Isn't this the same use case as scope-failure? (I don't buy the "must"
in "finalizing work in a destructor" but that's the same as
scope-failure, too.)

-- 
Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode

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