
17 Sep
2010
17 Sep
'10
5:56 p.m.
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; if(!std::uncaught_exception()) cout << "foo(): No Errors occurred!" << endl; else cout << "foo(): Exception caught!" << endl; BOOST_SCOPE_EXIT_END // ... }
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: http://www.gotw.ca/gotw/047.htm John Bytheway