HP aC++/HP C A.06.25 Programmer's Guide
Examples
Following are the examples for explicit and implicit instantiation:
Class Template
Following are examples of explicit and implicit instantiation syntax for a class template:
template <class T> class Array; // forward
// declaration
// for the
// Array class
// template
template <class T> class Array {/*...*/}; // definition
// of the Array
// class
// template
template class Array <int>; // request to
// explicitly
// instantiate
// Array<int>
// template class
Array <char> tc; // use of
// Array<char>
// template
// class which
// results in
// implicit
// instantiation
Function Template
Following are examples of explicit and implicit instantiation syntax for a function
template:
template <class T> void sort(Array<T> &); // declaration
// for the
// sort()
// function
// template
template <class T> void sort(Array<T> &v) {/* ... */};
// definition
// of the
// sort()
// function
// template
Invoking Compile-Time Instantiation 175