November 1999
Intermediate to advanced
240 pages
5h 22m
English
Difficulty: 7
Exception handling and templates are two of C++'s most powerful features. Writing exception-safe code, however, can be difficult—especially in a template, when you may have no idea when (or what) a certain function might throw your way.
We'll begin where Cargill left off—namely, by progressively creating a safe version of the Stack template he critiqued. Later on, we'll significantly improve the Stack container by reducing the requirements on T, the contained type, and show advanced techniques for managing resources exception-safely. Along the way, we'll find the answers to such questions as:
What are the different “levels” of exception safety?
Can or should generic containers be fully exception-neutral? ...