First page Back Continue Last page Summary Graphics

Basic Exception-safety guarantee


Notes:

Since m() doesn't run to completion we might reasonably expect that:
m() doesn't complete its task; but
if m() has opened a file, acquired a database connection, created a "heavyweight" GUI component or, more generally; if m() has "allocated a resource" then the resource should not leak. (The file or database connection must be closed, the component must be disposed of, ...); and
if m() changes a data structure, then that structure should remain useable.
These conditions - the basic exception safety guarantee - identify the first, and smaller peak of exception safety. Take a good look at it so that you’ll recognise it later.
The basic exception safety guarantee ensures that if m() updates the system state, then the state must remain usable. Note that isn’t quite the same as correct - for example, if m() were updating an address object part of the address may have been changed leaving a usable address object containing an incorrect address.