Subject: Re: [boost] D-style scope guards?
From: John Bytheway (jbytheway+boost_at_[hidden])
Date: 2010-09-17 13:56:30
On 17/09/10 11:37, Yakov Galka wrote:
> Why don't you use std::uncaught_exception() instead of exception_thrown?
> Also in my opinion this is a cleaner solution:
> void foo()
> BOOST_SCOPE_EXIT(empty capture list not supported yet)
> cout << "Returning from foo()" << endl;
> cout << "foo(): No Errors occurred!" << endl;
> cout << "foo(): Exception caught!" << endl;
> // ...
That won't work in general; std::uncaught_exception might return true
because of another pending exception that's going on 'outside' of foo()
(e.g. if foo() is called from a destructor).
For more details:
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk