Type Erasure - The Implementation Details
summary
Argues that type erasure gives value semantics and fewer dependencies than inheritance and demonstrates two ~20‑line Type Erasure Wrappers (owning and non‑owning), a stack‑friendly small‑buffer implementation and a shape view that avoids allocations. Benchmarks use 10,000 randomly generated shapes with 25,000 translate ops on an 8‑core Intel i7 (GCC/Clang); SBO yields about a 10% speedup in the presented run, manual replacement of virtual dispatch helps on some compilers but not all. Code compiles, runs, and preserves usability while enabling further optimizations.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:47Motivation and design
- 8:11Shape example and pattern
- 16:21Modernizing with wrapper
- 28:06Simplifying with value semantics
- 31:43Implementation details and dependencies
- 32:26Performance and benchmarks
- 35:18Small buffer optimization
- 47:29Advanced optimizations
- 51:18Virtual functions without overhead
- 56:16Summary
- 57:41Q&A
related talks
01h 01mBreaking Dependencies - C++ Type Erasure - The Implementation Details
01h 02mBreaking Dependencies: Type Erasure - A Design Analysis
44mPragmatic Type Erasure: Solving OOP Problems w/ Elegant Design Pattern
01h 03mBreaking Dependencies: type erasure - a design analysis
01h 01mPractical Type Erasure
01h 01mEmbracing (and also Destroying) Variant Types Safely
01h 10mstd::function: a deep dive behind the curtain
44mApplied modern C++: efficient expression evaluator with type erasure
