Summary
In this chapter, we went through a series of advanced topics. We started with name binding and dependent names and learned how to use the typename
and the template
keywords to tell the compiler what kind of dependent names we are referring to. Then, we learned about recursive templates and how to implement compile-time versions, using different approaches, for a recursive function.
We also learned about argument deduction for both function templates and class templates and how to help the compiler to do the latter with the help of user-defined deduction guides. An important topic covered in this chapter was the forwarding references and how they help us to implement perfect forwarding. Toward the end of the chapter, we learned about the decltype
type specifier, the std::declvalue
type utility, and, lastly, how friendship works in the context of class templates.
In the next chapter, we begin utilizing the knowledge accumulated so far about templates to do template metaprogramming...