CHAPTER 2

image

Small Object Toolkit

The previous chapter focused on the connection between template programming and style. In short, templates are elegant, as they allow you to write efficient code that looks simple because they hide the underlying complexity.

If you recall the introductory example of sq from Chapter 1, it’s clear that the first problem of TMP is choosing the best C++ entity that models a concept and makes the code look clear at the point of instantiation.

Most classic functions use internally temporary variables and return a result. Temporary variables are cheap, so you must give the intermediate results a name to increase the readability ...

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.