Polymorphism != Virtual: Easy, Flexible Runtime Polymorphism Without Inheritance
summary
Demonstrates a C++17 technique that provides runtime polymorphism without inheritance by shipping a polymorphic single-header (~247 lines) that builds per-interface vtables of trampoline function pointers and dispatches to overloads via a poly_extend mechanism. It implements polymorphic_ref/object types (value semantics, storable in containers), uses only standard C++17 and no macros, and reports sizes ~3× void for refs and ~4× void for objects with runtime performance clustered with other indirect-call approaches, so it works with acceptable overhead.
AI-written summary · about
chapters (17)
- 0:00Start
- 0:28What Is Polymorphism
- 1:02Polymorphism Actually Predated Object-Oriented Programming
- 3:01Overloading
- 7:35Value Semantics
- 8:03Low Coupling
- 16:31Wish List
- 17:54History Lesson
- 19:54Polymorphic Principle
- 20:52Function Graph
- 29:15Polymorphic Object
- 32:02Micro Benchmarks
- 32:46Final Assessment
- 33:52Generate Our Own Vtable
- 34:41Function Jump
- 35:28Build Av Table from Trampling Functions
- 44:44Using Types as Function Names
related talks
01h 23mRethink Polymorphism in C++
01h 35mRuntime Polymorphism: Back to the Basics
55mHow to "OO" in C++
01h 00mDynamic Polymorphism with Metaclasses and Code Injection
01h 08mRuntime Polymorphism: Back to the Basics
58mRust Traits In C++
01h 16mPolymorphism, Cohesion, and Coupling in C++
41mC++ Abstraction Patterns for Cross Platform Development in C++ Software Engineering
