Boost logo

Boost :

Subject: [boost] [exception] uncaught_exception_count, scope(failure), scope(success)
From: Evgeny Panasyuk (evgeny.panasyuk_at_[hidden])
Date: 2013-02-05 14:11:44


Hello All,

There is implementation of uncaught_exception_count -
https://github.com/panaseleus/stack_unwinding/blob/master/boost/exception/uncaught_exception_count.hpp
.

uncaught_exception_count is a function similar to
std::uncaught_exception from standard library, but instead of boolean
result it returns unsigned int showing current count of uncaught exceptions.

uncaught_exception_count allow us to implement scope(failure) and
scope(success) features from D language in C++. ( previous discussion is
at
http://boost.2283326.n4.nabble.com/scope-exit-D-style-scope-failure-and-scope-success-in-C-td4636441.html
)

Implementation of uncaught_exception_count is tested on {Clang 3.2, GCC
3.4.6, GCC 4.1.2, GCC 4.4.6, GCC 4.4.7, MSVC2005SP1, MSVC2008SP1,
MSVC2010SP1, MSVC2012} x {x32, x64}.

There are also live stress tests - detection of 500 simultaneous
uncaught exceptions:
GCC 4.6.3: http://liveworkspace.org/code/2qmSso%240
GCC 4.7.2: http://liveworkspace.org/code/dY0VD%240
Clang 3.2: http://liveworkspace.org/code/49MaPk%240

I think that uncaught_exception_count (and
uncaught_exception_count_latch primitive) can be added into
Boost.Exception library, at least into "detail" section.

After that scope(failure) and scope(success) features can be implemented
in Boost.ScopeExit library.
Note, approximately 14 of 16 Boost.ScopeExit examples in manual are in
fact emulations of scope(failure)/scope(success). So, looks like in
first place Boost.ScopeExit was introduced to simplify emulation of
scope(failure) and scope(success) features.

What do you think?

Thank you.

Best Regards,
Evgeny Panasyuk


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