C++ Reflection Is Not Contemplation
Talkat CppCon 2024 · on Wednesday, 2024-09-18· at 16:45· Maple 3/4/5, 6700 North Gaylord Rockies Boulevard·
summary
Argues that reflection without generation is useless and demonstrates concrete primitives that actually produce code: a two-line property specification expands into six working lines at compile time; a token-sequence design called token strings preserves macros and preprocessor expansion; a deferred injection primitive q_inject splices tokens into declaration contexts. Shows spec and AST APIs exist, notes a D-style string injection works, highlights identity-as-killer-app for cloning types and templates, and reports AI generated a 450-line std::vector clone in about nine seconds.
AI-written summary · about
chapters (21)
- 0:00Introduction
- 1:20The reflection problem
- 2:34Evolution of programming
- 5:36Code generation goals
- 9:17Property generation example
- 12:13Generating identifiers
- 13:29Splicing models comparison
- 20:27Token sequences
- 25:57Escapes and injection
- 27:38Property generation revisited
- 28:23Syntax and implementation
- 31:19Comparing APIs
- 32:44The role of identity
- 35:10Ship of Theseus paradox
- 37:41Identity function
- 43:39Min and Max functions
- 45:07Cloning types
- 47:08Cloning templates
- 49:04Future plans
- 51:31AI and reflection
- 55:15AI impact and Q&A
related talks
26mInfinite Possibilities
01h 00mDesign Idioms from an Alternate Universe
01h 07mDependency Injection Patterns: Efficiency and Usability
57mDesign Patterns - The Most Common Misconceptions (2 of N)
01h 04mThe Magic Behind Optimizing Compilers: Static Program Analysis
15mYou Might Not Need Classes
01h 00mHow to Use Dependency Injection to Write Maintainable Software
46mWords of Wisdom
