Embedded Reflections
summary
Argues that compile‑time reflection plus template metaprogramming produces concrete, faster code today using C++20/constexpr and a Godbolt/EDG prototype of the C++26 proposal. Demonstrates enum→string strategies: if‑else, switch with compiler heuristics (GCC prefers jump tables for clusters of ≥5 cases), and a compile‑time minimal perfect hash using BMI2 pxt (PEXT) hardware hash that maps enums to a packed buffer in about eight cycles. Builds a policy system to choose codegen (policy‑based selection), computes masks for 100 keys in under a second, and shows the approach works with clear size vs speed tradeoffs.
AI-written summary · about
chapters (11)
- 0:00Introduction to reflection
- 1:25Use cases for reflection
- 5:28Reflection syntax and power
- 9:07Introspection and embedding
- 12:21Code injection and state
- 18:05Enum naming case study
- 22:14Performance trade-offs
- 27:16Jump tables and switches
- 33:36Optimization heuristics
- 40:27Hardware-accelerated hashing
- 46:39Conclusion and Q&A
