Templates : Introduction
In
C++, it is common for the same abstract data structure to be applied to different
data types. For example, you could have a stack of integers, characters, or
pointers. Rather than create a new stack class for each type, a template allows
you to write generic type-independent code. A C++ template defines a family
of types or functions by creating a parameterized type. Parameterized types
can be used wherever actual types can be used. However, the template itself
is not a type.
Templates are part of the evolving C++ language. The
framework of the C++ language was created primarily by Bjarne Stroustrup.
His book, The C++ Programming Language, 2nd Edition, provides
good basic reference information but has limited coverage of templates.
Committee X3J16 has been working on an official standard
for C++ for several years. During this time, the committee has standardized
the existing features and added new features. Different implementations of
the C++ language support different sets of features, exhibit different limitations,
or exhibit different behavior in parts of the language that were not previously
well defined.
Beginning with Release 6.50, the SAS/C C++ Development
System supports templates as described in Stroustrup's book The C++
Programming Language, Second Edition, but implements clarifications
to the specification introduced by the ANSI draft C++ standard, as well as
a few language extensions. This appendix explains and clarifies the implementation
of templates as provided by the SAS/C C++ Development System. The descriptions
assume that you are already familiar with C++ templates.
Copyright © 2001
by SAS Institute Inc., Cary, NC, USA. All rights reserved.