A deep dive into implementing compile-time type lists in C++ template metaprogramming. Two approaches are compared: variadic template type lists (simpler syntax, C++11) and nested recursive type lists (more functional-style, faster compile times with real compilers). Benchmarks using GCC/Clang show nested type lists compile significantly faster despite being more verbose to write. The post walks through implementing core list operations — head/tail extraction, append, and concatenation — using template specialization and pattern matching, plus a trick for debugging types via intentional compile errors.

12m read timeFrom galowicz.de
Post cover image
Table of contents
All Roads Lead to RomeAdvantages/DisadvantagesExtracting Head and Tail of ListsAppending Items or Lists to a List’s TailI Want to see Something. How Do I Print Results?Outlook

Sort: