Compile-Time Counter Using Template & Constexpr Magic
summary
A zero-overhead compile-time counter implemented with templates, constexpr and overload resolution that auto-increments via chained static methods triggered from a class default initializer; it uses a templated integer wrapper and decltype trick so decltype(expression) sees newly declared overloads during class completion. Registration is emitted by macros into CS registerN calls, optimized by clang into a single tail-call sequence (tail-call optimized) while GCC leaves distinct functions; works within C++11, has a 255 wrapper limit on clang unless adjusted.
AI-written summary · about
chapters (5)
related talks
47mReducing Template Compilation Overhead, Using C++11, 14, 17, and 20.
01h 01mRethinking the Way We Do Templates in C++
57mIntroduction to C++ Template Metaprogramming
01h 03mUnderstanding The constexpr 2-Step
01h 03mOLD VERSION: Understanding The constexpr 2-Step
01h 37mRethinking the Way We Do Templates in C++ even more
01h 00mModern Template Metaprogramming: A Compendium, Part I
01h 30mRethinking the Way We Do Templates in C++
