HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)
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
template void sort<char> (Array <char>&); // request to
Invoking Compile-Time Instantiation 165