Dynamic Polymorphism With Code Injection and Metaclasses
summary
Argues that C++ dynamic polymorphism can be implemented without inheritance by generating type-erasure vtables and forwarding code via compile-time code injection, backed by a Clang fork prototype that uses experimental static reflection and metaclasses. Builds a templated "type-class" facade that auto-generates function-pointer vtables, copy/move/clone logic, and customizable storage policies (including small-buffer optimization) so objects keep value semantics, avoid intrusive base classes, support vectors of heterogeneous values, and let allocation strategy be chosen; the prototype works end-to-end.
AI-written summary · about
chapters (4)
related talks
01h 00mDynamic Polymorphism with Metaclasses and Code Injection
58mBetter Code: Runtime Polymorphism
59mMeta++: Language Support for Advanced Generative Programming
01h 23mRethink Polymorphism in C++
01h 41mC++ Type Erasure Demystified
01h 48m“Meta: Thoughts on generative C++”
41mVocabulary Types for Composite Class Design
58mRust Traits In C++
