A template is a pattern that lets the compiler write code for you.
Instead of repeating the same function or class for int,
float and std::string, you write it once with a type
parameter and the compiler generates each version when it is used. This module starts
with the basics of function templates and class templates.
It then covers template specialization, which lets you provide a custom version of a template for one particular type, and finishes with concepts, the C++20 feature that states what a type must support before it can be used with a template, giving clearer errors and safer generic code.
Watch the lessons in order, then continue on to STL: Containers & Algorithms.
How a template lets the compiler generate functions and classes from a pattern, with practical examples and when templates are worth using.
A hands-on webinar on writing function templates and class templates, and how the compiler instantiates them for each type you use.
How to specialize a class template for a specific type, including partial specialization, with worked examples.
Bjarne Stroustrup shows how C++ concepts express constraints on generic code and make templates safer and easier to use.