16.2.11 Default template arguments

back: templates
forward: standard library headers
fastback: exceptions
up: changeable c++
fastforward: compiler quirks
top: autoconf, automake, and libtool
contents: table of contents
index: index
about: about this document

A later refinement to C++ templates was the concept of default template arguments . Templates allow C++ types to be parameterized and as such, the parameter is in essence a variable that the programmer must specify when instantiating the template. This refinement allows defaults to be specified for the template parameters.

This feature is used extensively throughout the Standard Template Library (see section 16.2.13 Standard Template Library) to relieve the programmer from having to specify a comparision function for sorted container classes. In most circumstances, the default less-than operator for the type in question is sufficient.

If your compiler does not support default template arguments, you may have to suffer without them and require that users of your class and function templates provide the default parameters themselves . Depending on how inconvenient this is, you might begrudingly seek some assistance from the C preprocessor and define some preprocessor macros.

This document was generated by Gary V. Vaughan on May, 24 2001 using texi2html

GNU Autoconf, Automake and Libtool
GNU Autoconf, Automake, and Libtool
ISBN: 1578701902
EAN: 2147483647
Year: 2002
Pages: 290

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net