
----Original Message---- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Janek Kozicki Sent: 16 November 2006 07:04 To: boost@lists.boost.org Subject: Re: [boost] Review Request: Boost Exception
Peter Dimov said: (by the date of Wed, 15 Nov 2006 19:18:22 +0200)
Janek Kozicki wrote:
Peter Dimov said: (by the date of Wed, 15 Nov 2006 15:54:14 +0200)
e.dismiss();
why this? destructor of e does the work. No need to e.dismiss() Dave pointed out that std::uncaught_exception() inside e's destructor can check the conditions upon which the destructor is called and to the necessary work depending on it.
uncaught_exception may still return true in a destructor that is called during an ordinary return.
~X: called during stack unwinding
calls f()
void f() { Y y; } // ~Y is called here, uncaught_exception is true
So I have an idea - maybe put catch{} block inside destructor? :)
X::~X() { try { // try nothing. If exception is active, the catch() will get // activated :)
This is wrong. The catch will be activated ONLY by exceptions thrown from within the try block. Just because ~X() is being called because of stack unwinding caused by an active exception does NOT mean that the catch block will be entered. ... or did you mean something else?
} catch(boost::exception& e) { e.gotcha(); throw; // wow. It is a throwing destructor. What do you think? } }
I haven't tested that, maybe I'm just wrong :>
-- Martin Bonner Martin.Bonner@Pitechnology.com Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB24 6WZ, ENGLAND Tel: +44 (0)1223 203894