Chapter 4. Integral Type Wrappers and Operations

As we hinted earlier, the MPL supplies a group of wrapper templates that, like int_, are used to make integer values into polymorphic metadata. There’s actually more to these wrappers than meets the eye, and in this chapter we’ll uncover the details of their structure. We’ll also explore some of the metafunctions that operate on them, and discuss how best to write metafunctions returning integral constants.

4.1 Boolean Wrappers and Operations

bool is not just the simplest integral type, but also one of the most useful. Most of the type traits are bool-valued, and as mentioned earlier, play an important role in many metaprograms. The MPL type wrapper for bool values is defined this way:

   template< ...

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.