An Exception Correct C++ Singleton Template Base Class with Controlled Destruction Order

Peter Nordlund

Technical report CVAP246, ISRN KTH NA/P--00/14--SE. Department of Numerical Analysis and Computer Science, KTH (Royal Institute of Technology), S-100 44 Stockholm, Sweden, Oct 2000.

Abstract

This article describes some problems that may arise when trying to write exception safe C++ code and at the same time using STL. This is examplified with an implementation of a Singleton base class with a Destruction Manager that satisfies Abrahams' Strong Exception Guarantee [Abr97]. The Destruction Manager is based on the "Manager design pattern" by Sommerlad and Buschmann [SB96] and it destroys all instantiated Singletons in a controlled order. One part of the presented code is analyzed for exception safety in a more formal way, as suggested by Sutter [Sut99].

Postscript: (275 kb)

PDF: (272 kb)