CHAPTER 11

image

Debugging Templates

As TMP code induces the compiler to perform calculations, it’s virtually impossible to follow it step by step. However, there are some techniques that can help. This chapter in fact contains a mix of pieces of advice and debugging strategies.

11.1. Identify Types

Modern debuggers will always show the exact type of variables when the program is stopped. Moreover, a lot of information about types is visible in the call stack, where (member) functions usually are displayed with their full list of template arguments. However, you’ll often need to inspect intermediate results and return types.

The following function ...

Get Advanced Metaprogramming in Classic C++ 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.