Chapter 3. A Deeper Look at Metafunctions

With the foundation laid so far, we’re ready to explore one of the most basic uses for template metaprogramming techniques: adding static type checking to traditionally unchecked operations. We’ll look at a practical example from science and engineering that can find applications in almost any numerical code. Along the way you’ll learn some important new concepts and get a taste of metaprogramming at a high level using the MPL.

3.1 Dimensional Analysis

The first rule of doing physical calculations on paper is that the numbers being manipulated don’t stand alone: most quantities have attached dimensions, to be ignored at our peril. As computations become more complex, keeping track of dimensions is what ...

Get C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.