Skip to the content.

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:

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