Open Is Good: Fast, Orthogonal Open (Multi) Methods with YOMM2
summary
YOMM2 implements open methods (free, runtime-virtual functions) as a header-only C++ library and delivers multiple-dispatch plus plug-in extensibility without modifying existing class hierarchies. It builds dispatch tables at startup via a global perfect integer hash of type_info and an update step, adds support for friend/member methods, templated definitions and a virtual ptr fast-path, and can precompute offsets. Benchmarks show dispatch compiles to ~10 instructions and costs on the order of tens of cycles (measured ~15–65% slower than a raw virtual call), and the library is on GitHub, Compiler Explorer, vcpkg and Conan.
AI-written summary · about
chapters (15)
- 0:00Introduction and background
- 2:13Expression problem in C++
- 8:36Solutions to expression problem
- 10:02Open methods introduction
- 19:45YOMM2 implementation example
- 25:08Separating logic from data
- 29:50Performance comparison with virtual functions
- 33:04Multimethods and multiple dispatch
- 36:41Is this object-oriented?
- 41:02How YOMM2 works internally
- 53:01History and future of open methods
- 57:49Template support and macros
- 1:00:22How to use YOMM2
- 1:03:36Boost review and next steps
- 1:05:02Q&A and closing remarks
