[Exceptional C++ Style] Item 12: Exception Safety: Is it Wort h it?

Hammond, Peter peter.hammond at amsjv.com
Thu Dec 2 11:35:35 EST 2004


> Hello all,
> 
> 
> Summary for ITEM 12: Exception Safety: Is it Worth it?
> 
> 
> The author answers the question on whether it is worth writing
> exception-safe code or not.
> 
> 
<snip>
> The discussion then addresses why it is good to write code that
> satisfies at least one of these guarantees and which of them should be
> targeted depending on the situation.
> 

The article suggests, nay states, that all code needs to be exception safe.
This only true where the application needs to carry on after an exception.
This depends on what exceptions are used for of course, but in my experience
they are used to report very bad things in libraries, and the application
tells the user and gives up. In that case it doesn't much matter if it leaks
memory or other resources, or classes become unstable, because they are not
called any more.

Now I know this is a very simplistic view of the world, but it works. I read
thse articles and they make perfect sense, but then I try to apply them to
the day job and find that we are not going to continue anyway so it would be
a waste of effort. 

So how do you justify either using exceptions or not using them?
 
Ta,
Pete.

[ *** LongSig auto truncated *** ]



More information about the Effective-cpp mailing list