(ref.doc)template advantages
Prev: template terms
Up: cppR 5/2
Template advantages
by James Coggins, in cppR 5/2
1. Template names are scoped
2. The scopes of template definition and template instantiation are
separate, and the location where the template is used can only
affect the template through its formal parameters
3. Specialization lets the programmer extend the range of template
types beyond what could be handled by a simple-minded "macro"
system
4. Specialization lets the programmer provide additional semantics for
template argument types that require such capabilities
5. Template functions need not be instantiated if they are unneeded
6. User specializations need to be provided only when the program uses
them, and error messages from the compiler usually tell the
programmer when they must be provided
7. (dream) A clever compiler can take advantage of code commonality to
eliminate redundant routines (though a clever programmer won't
depend on it)
8. The source code looks just like any other source code, and can be
manipulated with the usual debuggers and browsers
automatically generated by info2www version 1.2.2.8