Is there life without RTTI or how to write your own dynamic_cast
summary
Shows a drop-in replacement for dynamic_cast that removes RTTI by putting a runtime tag into the base object and using either embed numeric tag in base or a macro to generate mappings and a third classof-style static check approach similar to Clang. Tests on an AST with randomized vectors of derived nodes show the custom casts run dramatically faster (dynamic_cast measured ~37× slower here). Works for single inheritance and saves binary/runtime cost but needs per-class boilerplate and fails for virtual inheritance or complex multiple-inheritance layouts.
AI-written summary · about
chapters (6)
- 0:00Introduction
- 2:04Standard dynamic_cast problems
- 4:54Alternative with metadata
- 7:45Type-casting logic encapsulation
- 10:15Approach comparison and benchmarks
- 12:22Test results and conclusions
related talks
22mLink-Time Optimization of Dynamic Casts in C++ Programs
05mGeneralised Double Dispatch
01h 33mDe-fragmenting C++: Making Exceptions and RTTI More Affordable and Usable
01h 07mDynamic Polymorphism With Code Injection and Metaclasses
58mBetter Code: Runtime Polymorphism
01h 37mRethinking the Way We Do Templates in C++ even more
01h 23mRethink Polymorphism in C++
04mAvoiding Virtual Call in CRTP
