Lecture overview -- Keyboard shortcut: 'u'  Previous page: Function templates -- Keyboard shortcut: 'p'  Next page: Example of Policies with Templates -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 5 - Page 8 : 39
Notes about C++
Templates and The Standard Library
Policies with Templates

A type parameter can be used to parameterize a class or function with a class that represent a given policy

For instance a set of functions that compare data in a certain way

  • The C++ Programming Language: Page 338
 

  • Why use templates for policies

    • As an alternative to a function parameter, or to an instance of a class with virtual functions

    • Use of templates will typically give more efficient programs

      • Compile time substitutions

See details in §13.4 in The C++ Programming Language