Boost logo

Boost :

Subject: Re: [boost] [exception] uncaught_exception_count, scope(failure), scope(success)
From: Evgeny Panasyuk (evgeny.panasyuk_at_[hidden])
Date: 2013-02-06 14:16:10


06.02.2013 16:36, Vicente J. Botet Escriba:
> Hi,
> +1 for both inclusions.

Thank you for interest.

06.02.2013 7:30, Andrey Semashev:
>>
>> I was asking specifically how uncaught_exception_count would be used.
>
> I'm using uncaught_exception_count in a few places of Boost.Log to implement
> guards that do the main work in destructor and only when an exception is not
> being thrown. For instance, this expression:
>
> BOOST_LOG(lg) << foo();
>
> will create a guard object that will collect the result of foo into a stream
> and emit a log record on destructor if foo doesn't throw.

Thank you, that is interesting example - without
uncaught_exception_count it would be not easy to achieve same syntax.

However, here is my attempt: http://ideone.com/ynQ2XX .
And honestly, if that "for"-based approach would cover all your needs -
I would prefer it instead of uncaught_exception_count - because it is
more portable.
Though uncaught_exception_count still has some good use cases.

-- 
Evgeny Panasyuk

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