Skip to content

Defined Terms

  • class template Definition from which specific classes can be instantiated. Class templates are defined using the template keyword followed by a comma-separated list of one or more template parameters enclosed in < and > brackets, followed by a class definition.

  • default template arguments A type or a value that a template uses if the user does not supply a corresponding template argument.

  • explicit instantiation A declaration that supplies explicit arguments for all the template parameters. Used to guide the instantiation process. If the declaration is extern, the template will not be instantiated; otherwise, the template is instantiated with the specified arguments. There must be a nonextern explicit instantiation somewhere in the program for every extern template declaration.

  • explicit template argument Template argument supplied by the user in a call to a function or when defining a template class type. Explicit template arguments are supplied inside angle brackets immediately following the template’s name.

  • function parameter pack Parameter pack that represents zero or more function parameters.

  • function template Definition from which specific functions can be instantiated. A function template is defined using the template keyword followed by a comma-separated list of one or more template parameters enclosed in < and > brackets, followed by a function definition.

  • instantiate Compiler process whereby the actual template argument(s) are used to generate a specific instance of the template in which the parameter(s) are replaced by the corresponding argument(s). Functions are instantiated automatically based on the arguments used in a call. We must supply explicit template arguments whenever we use a class template.

  • instantiation Class or function generated by the compiler from a template.

  • member template Member function that is a template. A member template may not be virtual.

  • nontype parameter A template parameter that represents a value. Template arguments for nontype template parameters must be constant expressions.

  • pack expansion Process by which a parameter pack is replaced by the corresponding list of its elements.

  • parameter pack Template or function parameter that represents zero or more parameters.

  • partial specialization Version of a class template in which some some but not all of the template parameters are specified or in which one or more parameters are not completely specified.

  • pattern Defines the form of each element in an expanded parameter pack.

  • template argument Type or value used to instantiate a template parameter.

  • template argument deduction Process by which the compiler determines which function template to instantiate. The compiler examines the types of the arguments that were specified using a template parameter. It automatically instantiates a version of the function with those types or values bound to the template parameters.

  • template parameter Name specifed in the template parameter list that may be used inside the definition of a template. Template parameters can be type or nontype parameters. To use a class template, we must supply explicit arguments for each template parameter. The compiler uses those types or values to instantiate a version of the class in which uses of the parameter(s) are replaced by the actual argument(s). When a function template is used, the compiler deduces the template arguments from the arguments in the call and instantiates a specific function using the deduced template arguments.

  • template parameter list List of parameters, separated by commas, to be used in the definition or declaration of a template. Each parameter may be a type or nontype parameter.

  • template parameter pack Parameter pack that represents zero or more template parameters.

  • template specialization Redefinition of a class template, a member of a class template, or a function template, in which some (or all) of the template parameters are specified. A template specialization may not appear until after the base template that it specializes has been declared. A template specialization must appear before any use of the template with the specialized arguments. Each template parameter in a function template must be completely specialized.

  • type parameter Name used in a template parameter list to represent a type. Type parameters are specified following the keyword typename or class.

  • type transformation Class templates defined by the library that transform their given template type parameter to a related type.

  • variadic template Template that takes a varying number of template arguments. A template parameter pack is specified using an elipsis (e.g., class. . ., typename. . ., or type-name. . . ).