SourcePro Analysis : Essential Math Module User’s Guide : Templatized Collection Classes
Templatized Collection Classes
Templates Defined
The concept of templates is basic to the Essential Math Module, and so we begin here. A template is a class declaration parameterized on a type. It is a prescription for how a particular kind of collection should behave. For example, RWMathVec<T> is a template that describes such things as how to index an element, how long it is, how to resize it, and so on. The template establishes a framework for a type you can specify later.
The vector, matrice, and array classes are the collection classes of the Essential Math Module. All of these basic classes are templatized.
Here's how these template classes work. Let's say you request a vector of a particular type, perhaps a vector of doubles such as RWMathVec<double>. The compiler goes back to the template declaration and fills it in for the type double. You get the same result as if you had handwritten a class VectorOfDoubles, but you don’t have to do the writing. Instead, the compiler automatically generates the logical equivalent of the specified class.