POOMA extensively uses C++ templates to support type polymorphism without incurring any run-time cost. In this chapter, we briefly introduce using templates in C++ programs by relating them to "ordinary" C++ constructs such as values, objects, and classes. The two main concepts underlying C++ templates will occur repeatedly:
Template programming constructs execute at compile time, not run time. That is, template operations occur within the compiler, not when a program runs.
Templates permit declaring families of classes using a single declaration. For example, the Array template declaration permits using Arrays with many different value types, e.g., arrays of integers, arrays of floating point numbers, and arrays of arrays.
For those interested in the implementation of POOMA, we close the section with a discussion of some template programming concepts used in the implementation but not likely to be used by POOMA users.