FAQ Part 10: Templates and STL

What are templates?

Templates allow writing generic functions/classes.

template <typename T>
T max(T a, T b) {
    return a > b ? a : b;
}

What is the Standard Template Library (STL)?

STL is a collection of template classes and functions:

  • Containers: vector, list, set, map
  • Algorithms: sort, find, count
  • Iterators: Traverse containers