
At Sun, 15 Aug 2010 16:08:47 -0700, Emil Dotchevski wrote:
If I keep careful control over my exception types---for example, if I only throw PODs---I can reasonably expect that "throw x;" throws x
You can reasonably expect that even for non-PODs. By the time you end up getting a std::bad_alloc, I don't think it matters much whether it is emitted from some operator new or from a throw (possibly indirectly, from an exception object which allocates memory in its consturctor)
My point is that whether that matters to the application is not for you---the library author---to decide.
-- your process is in a pretty bad state already.
I wouldn't say that. Out-of-memory is a condition from which recovery is perfectly manageable.
The reason why I'm reacting to this type of concerns is that typically they're motivated by a desire to control exactly what exceptions a particular function is permitted to emit. It is this type of concerns that have lead to the infamous exception specifications in the standard.
Agreed.
In other cases, these concerns lead to exception type translation code which usually can be summarized as "catch(x) { throw y(x); }. Often, this doesn't make it easier to deal with x, but now the code that deals with x is coupled with y too.
Yup. -- Dave Abrahams BoostPro Computing http://www.boostpro.com