In this chapter, we will learn advanced template programming techniques. These techniques include the ability to change the implementation of a template class based on the type that is provided, how to work different types of arguments including how to properly forward them, how to optimize your code both at runtime and compile time, and how to use some new features added to C++17. This is important because it provides a better understanding of how template programming works as well as how to ensure your templates are performing the way you expect.
Too often, we write template code assuming it is executing one way when, in fact, it is executing in another, either generating unreliable code, code with unexpected performance penalties, or both. This chapter will explain how to avoid these issues and provide the foundation for writing proper...