February 2005
Beginner to intermediate
272 pages
4h 53m
English
The hard part about writing exception safe code isn’t the throwing or catching of exceptions; it’s everything in between. As a thrown exception wends its way from the throw expression to the catch clause, every partially executed function on that path must “clean up” any important resources that it controls before its activation record is popped off the execution stack. Generally (but not always), all that is required to write an exception safe function is a moment’s reflection and some common sense.
For example, consider the implementation of String assignment from Assignment and Initialization Are Different [12, 41]:
The implementation of this function may look superfluously ornate, since we could have coded ...
Read now
Unlock full access