There is no silver bullet
summary
Claims that std::variant is not a drop-in replacement for virtual functions and that design choices beat single features. Builds three concrete solutions for a shape-drawing system: classic base-class + virtual functions, a variant-based functional approach (measured as much faster in microbenchmarks), and a value-based type-erasure wrapper that restores OOP extensibility with similar runtime cost and optional SBO. Notes template-heavy designs blow up compile times in very large codebases, advises choosing and documenting architecture with ADRs. type erasure gives value semantics and pick by dependency and extensibility needs.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 1:03Simple shapes example
- 8:41Gang of Four patterns
- 13:17Replacing inheritance with std::variant
- 22:33Flaws in variant approach
- 25:19Templates to invert dependencies
- 28:09std::variant not silver bullet
- 31:40Software design in C++
- 34:54Progressive C++ rethink
- 36:47Type erasure with shape model
- 43:10Simplifying with type erasure
- 47:28Performance comparison
- 51:40Choosing the right solution
- 53:29Summary
related talks
01h 24mKeynote: Optimizing for Change
05m10 Things Junior C++ Devs Don't Get
01h 52mThe evolving search for effective C++ - Keynote
26mC++ UNIverse
01h 51mProg C++
02h 02mBelle Views on C++ Ranges, their Details and the Devil
01h 29m“Simplicity: Not Just For Beginners”
01h 39m“Learning and Teaching Modern C++”
