Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

9.6 The Guard Class with Templates

If your compiler supports templates, you can use the guard class to guarantee that the acquire() and release() functions are called in pairs. The guard class is not provided by DBTools.h++; it must be supplied by your application. Here is how it looks:

The guard class expects type T to provide the acquire() and release() functions. If type T provides them, the functions are called in the constructor and destructor, respectively; if type T does not, the compiler should flag an error. Nearly all DBTools.h++ classes provide the necessary interface used by the guard class. The guard class can be applied as follows:


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.