Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 874
News FAQ
Search Home


next up previous contents index
Next: Instantiation mechanisms Up: Template instantiation Previous: Template instantiation

C++ template classes

AIPS++ makes heavy use of C++ template classes, also referred to as ``parameterized types''. These are typically used to implement ``container'' classes, for example Set, List, and Array classes, which serve to aggregate objects of another type. In C++, Set would be defined in ``template'' form as Set<T>, where the template type (or parameter), T, represents some as yet unspecified data type. This saves having to code Set classes separately for int, float, or general Object data types.

The C++ compiler ``instantiates'' the Set<T> class template for objects of type float (say) when it compiles a piece of code which declares that it wants to use Set<float>.

Global functions can also be templated. The argument list and return value may be defined in terms of template type T, where T often (but not necessarily) refers to a template class.

It often happens that particular template classes and functions can be implemented more efficiently for a particular template type by manual coding rather than by instantiation of the class or function template. C++ allows ``template specializations'' to be written for particular instances of template classes, but some compilers may require these to be registered in a particular way.


next up previous contents index
Next: Instantiation mechanisms Up: Template instantiation Previous: Template instantiation   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2004-11-13