Week 11: Template Metaprogramming
🔗 Pre-Class Learning Material
After watching waaay too many talks on template metaprogramming, I think this one is a good choice to start some good discussion:
- CppCon 2015: Fedor Pikus “C++ Metaprogramming: Journey from simple to insanity and back”
- quick-bench reproduction of the Pow profiling result reported in the talk: O1 and O3
Nitash has some good suggestions below. What I really came out of this understanding is just how hard modern C++ compilers have been working to simplify and eliminate the need for meta programming. One big help is fold expressions. Let’s also watch this short (<8 minute) summary of them:
optional extra material…
For those of you who want something more (NOT required!) here is Herb Sutter talking about how to replace template meta programming with more sensible alternatives:
A brief, example-driven primer on using SFINAE to test for the presence of a member function in a struct contributed by @cgnitash. (Find the example code all spliced together on Compiler Explorer here).
Also, reccomended by @cgnitash: CppCon 2014: Walter E. Brown “Modern Template Metaprogramming: A Compendium, Part I”.
🔗 In-Class Material
- Godbolt link with template metaprogramming live coding from class