Sign up for the KDAB Newsletter
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Find what you need - explore our website and developer resources
14 December 2022
This is the first of four episodes in a mini series on templates. The aim of the series is to help you understand some relatively complex template code.
In this episode we will start slowly understanding what a template is, but within 15 minutes we will have seen the assembly code generated, have discussed template type parameters and non-type parameters, and finally have discussed template template parameters (no that is not a mistake that it says template twice!)
Links:
* Good book on templates : http://tmplbook.com/
* Description of template parameters: https://en.cppreference.com/w/cpp/language/template_parameters
* Video on how to put templates in the cpp file: https://youtu.be/msWQpGGNsoo?list=PL6CJYn40gN6gf-G-o6syFwGrtq3kItEqI&t=1385
* Links to our trainings: https://training.kdab.com/
0:00 Introduction
1:38 template methods
4:55 A stack implementation
8:30 templates only compiles the code it needs
10:25 Stacks of maximum n-items
13:20 Default type parameters
16:02 template template type parameter
17:46 variadic template parameters
The example code showcased in this video is available here: https://github.com/KDAB/kdabtv/tree/master/Qt-Widgets-and-more/template-mini-series/episode1
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Learn Modern C++
Our hands-on Modern C++ training courses are designed to quickly familiarize newcomers with the language. They also update professional C++ developers on the latest changes in the language and standard library introduced in recent C++ editions.
Learn more