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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.