Thoughts on Curiously Recurring Template Pattern
summary
Modern CRTP is presented as a tool for actual code reuse over interface, shown by collapsing repeating inner-loop code across several widget implementations into a single template pattern. Several surprising compile-time behaviors appear: returning CRTP types, using auto with CRTP, and the compiler needing complete size information before deriving. Practical rules emerge: hide static_casts, use concepts not base class and keep implementation classes in an impl namespace, prefer defaults, avoid protected data members, and use a sentinel + is_same pattern to recur through middle layers.
AI-written summary · about
chapters (3)
related talks
01h 30mRethinking the Way We Do Templates in C++
01h 01mRethinking the Way We Do Templates in C++
01h 00mModern Template Metaprogramming: A Compendium, Part I
57mIntroduction to C++ Template Metaprogramming
56mExploring Dependency Injection and Reflection in Modern C++
50mExpression Templates: Past, Present, Future
01h 00mConcepts in C++20: Revolution or Evolution
01h 06m“C++ Metaprogramming: Journey from simple to insanity and back"
