Rethinking the Way We Do Templates in C++
summary
Implements a Physical Units Library and shows concrete fixes: replace deep class-template aliasing with inherited strong typedefs plus a manual dumb casting facility to keep type names readable; switch many metaprogramming helpers to constexpr value-returning functions or non-type template parameters to shrink instantiation graphs; adopt C++20 concepts for clear compile-time contracts. Uses MetaBench for microbenchmarks: function-style constexpr/NTTP forms compile much faster for operations, NTTP construction is slower, concepts cost ≈10% only if applied everywhere; follow the Rule of Cheil and prefer aliases/variable templates for speed.
AI-written summary · about
chapters (6)
- 0:00Introduction and motivation
- 1:52User experience challenges
- 19:37New tools for C++
- 30:19Concepts in C++20
- 41:37Performance of metaprogramming
- 56:58Conclusion and Q&A
related talks
01h 30mRethinking the Way We Do Templates in C++
01h 00mModern Template Metaprogramming: A Compendium, Part I
57mIntroduction to C++ Template Metaprogramming
59mHow and When To Write a C++ Template
01h 06m“C++ Metaprogramming: Journey from simple to insanity and back"
01h 21mWhat Has C++20 Ever Done For Templates?
50mExpression Templates: Past, Present, Future
01h 28mModern C++ Design reloaded
