Boost logo

Boost :

From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2023-04-06 18:26:26


Hi Everyone,
It is my understanding that the reason scope_fail was left to die in the
C++ Extensions for Library Fundamentals v3 was that it is not
implementable. One cannot detect if the scope is being left due to an
exception thrown from within the scope. Observing the number of uncaught
exceptions in the constructor and in the destructor will not work, given
that we now have coroutines that can be suspended and then resumed in
another thread (with a different number of uncaught exceptions), or even in
the same thread but at some later point, when the number of uncaught
exceptions has changed.

The enclosed example illustrates how a scope_fail fails to call the
callback when an exception is thrown from a coroutine. It uses Lewis
Baker's CppCoro implementation of a generator.

The only reliable way to call a callback when the scope is left due to an
exception is through using the explicit call to `deactivate()` function. It
is more verbose, but reliable.

Regards,
&rzej;




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