CHAPTER 3
Static Programming
Templates are exceptionally good at forcing the compiler and optimizer to perform some work only when the executable program is generated. By definition, this is called static work. This is as opposed to dynamic work, which refers to what is done when the program runs.
Some activities must be completed before runtime (computing integer constants) and some activities have an impact on runtime (generating machine code for a function template, which is later executed).
TMP can produce two types of code—metafunctions, which are entirely static (for example, a metafunction unsigned_integer<N>::type that returns an integer ...
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.