Reflections: Compile-time Introspection of Source Code
summary
Proposal: a static reflection system for C++ that exposes source-level declarations as a single compile-time meta value, implemented in a clang fork and demoed on Compiler Explorer; it uses a reflects operator to get meta handles, consteval/immediate functions as the compile-time boundary, and expansion statements plus reification (value_of/type_name) to generate code. Examples: enum-to-string, structural hashing, and a partial runtime introspection library (nemesis); it mostly works but has compile-time performance tradeoffs (user-defined types slow some compilers 3–9x) and some examples require the experimental compiler.
AI-written summary · about
chapters (7)
- 0:00Introduction to static reflection
- 9:49Why static reflection matters
- 16:07Stringification with reflection
- 33:11Structural hashing example
- 45:53Runtime introspection demo
- 55:27Pattern behind reflection use
- 57:32Final thoughts and Q&A
related talks
01h 01mReflection
01h 27mC++ Reflection - Back on Track
01h 10mReflection Is Good for C++ Code Health
01h 04mWelcome to v1.0 of the meta::[[verse]]!
46mBuilding a C++ Reflection System in One Weekend Using Clang and LLVM
36mCompile-time reflection, Serialization and ORM
55mC++14 Reflections Without Macros, Markup nor External Tooling..
01h 18mReflection API for Modern C++
