Pragmatic Type Erasure: Solving OOP Problems w/ Elegant Design Pattern
summary
Claims that proper type erasure solves lifetime, ownership and multiple-interface OOP problems without losing performance and compares hand-rolled implementations to boost type erasure with measured timings. Demonstrates small buffer optimization, copy‑on‑write and ref_wrapper tricks to avoid heap churn, shows where heap allocations remain, and delivers a code generator using libclang that emits erased types from real headers. Source, slides and runnable examples appear on the conference GitHub and the implementations validate the performance and usability claims.
AI-written summary · about
chapters (14)
- 0:00OUTLINE
- 0:27THE IMPORTANCE OF VALUES
- 1:48EQUATIONAL REASONING
- 2:56WHY POLYMORPHISM?
- 5:50(PROBLEMS WITH) INHERITANCE AS RUNTIME POLYMORPHISM
- 10:48A QUICK CASE STUDY: WIDGETS AND LAYOUTS
- 12:09(PROBLEMS WITH) TEMPLATES AS COMPILE- TIME POLYMORPHISM
- 17:10MAKING MAGIC HAPPEN
- 29:16USE A COPY-ON-WRITE WRAPPER Instead of always copying our type erased objects.only copy them when they are mutated
- 31:26INTEGRATE COPY-ON-WRITE INTO ERASED TYPES Remove one set of allocations on construction by applying copy on write directly to the handle member.
- 31:43APPLY THE SMALL BUFFER OPTIMIZATION
- 37:26CAVEATS
- 40:46Archetype input
- 41:50Erased type output
related talks
01h 03mType Erasure - The Implementation Details
01h 02mBreaking Dependencies: Type Erasure - A Design Analysis
01h 03mBreaking Dependencies: type erasure - a design analysis
01h 01mBreaking Dependencies - C++ Type Erasure - The Implementation Details
01h 03mWriting sustainable software. The how and the what!
01h 01mEmbracing PODs Safely Until They Die
56mC++ Relocation - How to Achieve Blazing Fast Save and Restore and More!
01h 05mExpressing Implementation Sameness and Similarity - Polymorphism in Modern C++
