Better Code: Runtime Polymorphism
summary
Shows how to get runtime polymorphism in C++ without class inheritance by building a template-based runtime concept idiom that stores models via rvalue refs, move semantics, make_unique/make_shared, RVO and ADL-picked draw functions. Implements a drawable-any, a Document container and a History stack that uses light copy-on-write tiles (Photoshop demo) and value semantics with shared_ptr<const> to avoid races. Works with third-party types, matches inheritance performance, and trades off verbosity and tricky multi‑concept cases.
AI-written summary · about
chapters (19)
- 0:00Start
- 2:35What Is Inheritance
- 4:18Guidelines
- 8:27Operation Semantics
- 11:15Copy Constructors
- 12:03Elements of Programming
- 14:01Polymorphism Is Intrusive
- 19:25Copy Constructor
- 19:37Assignment Operator
- 26:01Sync Arguments
- 28:07Move Constructor
- 29:51Language Defect
- 33:23Drawable Object
- 34:22Virtualize Copy
- 34:32Virtual Copy
- 40:15Photoshop History Panel
- 43:09History Brush
- 48:59Observer Function
- 53:58Drawbacks to this Approach
related talks
01h 23mRethink Polymorphism in C++
01h 07mDynamic Polymorphism With Code Injection and Metaclasses
57mA Tour of Polymorphism Techniques in C++
55mHow to "OO" in C++
58mRust Traits In C++
55mBreaking Dependencies: Type Erasure - The Implementation Details
01h 16mPolymorphism, Cohesion, and Coupling in C++
01h 07mC++20 Concepts: A Day in the Life
