|
VMS Help CXXL, generic_package *Conan The Librarian |
The generic package provides ways to simulate parameterized types by
allowing the instantiation of class declarations using the macro
facilities of the DEC C++ preprocessor. You can use the generic
package to construct container classes. The actual types of the data
members are passed at compile time as parameters to the class when
you use the class name.
Header:
#include <generic.hxx>
To declare a generic type:
1. Define a name for the class and specify the number of type
parameters:
o To specify one type parameter, use the name2 macro
o To specify two type parameters, use the name3 macro
For example:
#define myclass(mytype) name2(myType, myClass)
2. Define the class body as a macro. For example:
#define myclass declare(myParam) class {...}
#define myclass implement(myParam) ...
3. Declare the actual class (any valid C++ type). For example:
declare(myClass, T)
By substituting one or another class, you can declare multiple
instances of the generic class template with various component types.
For example, depending on the type parameter you use, you can declare
such types as list of int, list of strings, or list of lists.
|
|