Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Interface Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

11.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 the DB Interface Module; 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 classes of the DB Interface Module provide the necessary interface used by the guard class. The guard class can be applied as follows:

Example 13: Using a guard class with templates



Previous fileTop of DocumentContentsIndex pageNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.