Appendix: Closing Notes

We are now at the end of this book. 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 you’re writing, you’ll be using templates daily.

We started the book 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 chapter, we learned about templates with variable numbers of arguments, which are called variadic templates. The next chapter was dedicated to more advanced template concepts, such as name binding, recursion, argument deduction, and forwarding references.

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 sixth chapter 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.

In the final part of the book, 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 type lists. 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 chapter was dedicated to the C++20 ranges library, where we learned about ranges, range adaptors, and constrained algorithms.

By reaching this point, you have completed this journey of learning metaprogramming with C++ templates. However, this learning process doesn’t end here. A book can only supply you 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 book without practicing what you have learned is futile. Your task now is to put into practice the knowledge you have acquired from this book 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.

I hope this book will prove to be a valuable resource for you in reaching the goal of becoming prolific with C++ templates. While developing this book, I tried to find the right balance between simplicity and meaningfulness so that it makes it easier for you to learn this difficult topic. I hope I succeeded in doing that.

Thank you for reading this book, and I wish you good luck putting it into practice.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset