Conclusion
Go over the key takeaways of the course with a roadmap of the next steps.
We'll cover the following...
We are now at the end of this course. Templates are not the easiest part of C++ programming. Indeed, people usually find them difficult or horrendous.
However, templates are heavily used in C++ code, and it’s likely that whatever kind of code we’re writing, we’ll be using templates daily.
Core template concepts
We started the course by learning what templates are and why we need them. We then learned how to define function templates, class templates, variable templates, and alias templates. We learned about template parameters, specialization, and instantiation. In the third section, we learned about templates with variable numbers of arguments, which are called variadic templates.
The next section was dedicated to more advanced template concepts, such as name binding, recursion, argument deduction, and forwarding references.
Advanced template features
We then learned about the use of type traits, SFINAE, and constexpr if, and we explored the collection of type traits available in the standard library. The next section was dedicated to concepts and constraints, which are part of the C++20 standard.
We learned how to specify constraints for template arguments in different ways and how to define concepts and everything related to them. We also explored the collection of concepts available in the standard library.
Applied templates
In the final part of the course, we focused on using templates for practical purposes. First, we explored a series of patterns and idioms, such as the CRTP, mixins, type erasure, tag dispatching, expression templates, and typelists. Then, we learned about containers, iterators, and algorithms, which are the pillars of the Standard Template Library, and wrote some of our own.
Finally, the last section was dedicated to the C++20 ranges library, where we learned about ranges, range adaptors, and constrained algorithms.
What’s next?
By reaching this point, we have completed this journey of learning metaprogramming with C++ templates. However, this learning process doesn’t end here. A course can only supply us with the necessary information to learn a topic, structured in such a way that makes it easy to understand and follow that topic. But reading a course without practicing what we have learned is futile. Your task now is to put into practice the knowledge you have acquired from this course at work, at school, or at home. Because only by practicing will you be able to truly master not only the C++ language and metaprogramming with templates but also any other skill.
We hope this course will prove to be a valuable resource for you in reaching the goal of becoming prolific with C++ templates. While developing this course, we tried to find the right balance between simplicity and meaningfulness so that it makes it easier for you to learn this difficult topic. We hope we succeeded in doing that.
Thank you for reading this course, and we wish you good luck putting it into practice.