Reducing Template Compilation Overhead, Using C++11, 14, 17, and 20.
summary
Investigates concrete ways to cut heavy template compile costs: replaces deep recursive template instantiations with memoized templates and std::integral_constant wrappers, converts recursion that blows up at 27–28 to if constexpr or template memoization, collapses n^3 tuple instantiation to near O(n) via index_sequence leaf inheritance, and swaps std::enable_if for cleaner C++20 constraints. Reports real effects: builds that hit ~10 GB RAM or fail; GCC handles one case in <0.5s while MSVC takes ~10s; the shown wrappers and using-declaration moves drastically reduce instantiations and debug-symbol bloat.
AI-written summary · about
chapters (10)
- 0:00Introduction
- 0:13The problem of template bloat
- 1:08Background on template costs
- 9:45Function signature mangling
- 12:07Implementing an efficient tuple
- 27:05Reducing instantiation overhead
- 37:18API contracts and behavior
- 37:39Advanced template tricks
- 39:04Future of compiler optimization
- 42:48Q&A
related talks
01h 37mRethinking the Way We Do Templates in C++ even more
01h 30mRethinking the Way We Do Templates in C++
57mIntroduction to C++ Template Metaprogramming
01h 06m“C++ Metaprogramming: Journey from simple to insanity and back"
50mPruning Error Messages From C++ Template Code
50mC++ Costless Abstractions: the compiler view
55mTemplates Made Easy With C++20
01h 03mBack to Basics: Templates (part 2 of 2)
