
31 Oct
2009
31 Oct
'09
11:48 a.m.
Detlef Vollmann wrote:
But the basic problem of throwing exceptions from destructors exists, and is IMO a major flaw of how exception handling works in C++, but I don't think that this will change.
FWIW, the language allows to work around this problem. You can use std::uncaught_exception to detect whether to throw exception in a destructor or not. Regarding the original idea of returning an object that would throw in its destructor, I don't see this problem at all, as this object can only be returned if there is no exception propagating. However, I can't say I'm in favor of this idea.