The article introduces 'rjk::duck', a C++ library leveraging experimental C++26 reflection features to simplify type erasure, eliminating the boilerplate associated with libraries like Boost.TypeErasure. It demonstrates how to define interfaces once and automatically generate vtables and adapt various standard containers at runtime with minimal overhead.
Background
Type erasure is a common C++ technique for achieving polymorphism without inheritance, often requiring significant boilerplate or heavy libraries. C++26's reflection capabilities offer new opportunities to automate this process dynamically.
- Source
- Lobsters
- Published
- Jul 14, 2026 at 08:58 PM
- Score
- 7.0 / 10