13.7 — Partial template specialization

This lesson and the next are optional reading for those desiring a deeper knowledge of C++ templates. Partial template specialization is not used all that often (but can be useful in specific cases).

In lesson 13.4 — Template non-type parameters, you learned how expression parameters could be used to parameterize template classes.

Let’s take another . . . → Read More: 13.7 — Partial template specialization

13.6 — Class template specialization

In the previous lesson 13.5 — Function template specialization, we saw how it was possible to specialize functions in order to provide different functionality for specific data types. As it turns out, it is not only possible to specialize functions, it is also possible to specialize an entire class!

Consider the case where you want . . . → Read More: 13.6 — Class template specialization

13.4 — Template non-type parameters

In previous lessons, you’ve learned how to use template type parameters to create functions and classes that are type independent. However, template type parameters are not the only type of template parameters available. Template classes and functions can make use of another kind of template parameter known as a non-type parameter.

Non-type parameters

A template . . . → Read More: 13.4 — Template non-type parameters

13.3 — Template classes

In the previous two lessons, you learn how 13.1 — Function templates, which get instantiated into 13.2 — Function template instances, allow us to generalize functions to work with many different data types. While this is a great start down the road to generalized programming, it doesn’t solve all of our problems. Let’s take a . . . → Read More: 13.3 — Template classes

13.2 — Function template instances

It’s worth taking a brief look at how template functions are implemented in C++, because future lessons will build off of some of these concepts. It turns out that C++ does not compile the template function directly. Instead, at compile time, when the compiler encounters a call to a template function, it replicates the template . . . → Read More: 13.2 — Function template instances

13.1 — Function templates

The need for function templates

In previous chapters, you’ve learned how to write functions and classes that help make programs easier to write, safer, and more maintainable. While functions and classes are powerful and flexible tools for effective programming, in certain cases they can also be somewhat limiting because of C++’s requirement that you specify . . . → Read More: 13.1 — Function templates