Beautiful Type Erasure with C++26 Reflection
C++26's new reflection capabilities enable the `rjk::duck` library to simplify type erasure by allowing developers to define interfaces once using annotations, eliminating the need for 100+ lines of boilerplate code previously required by libraries like Boost.TypeErasure. The library uses C++26 reflection to automatically generate tags and vtables, enabling runtime polymorphism while preserving customization and performance across different container types. Currently available only for GCC with C++26 support, duck offers owning/non-owning semantics, operators, and interface composition in a single header file.
Read Full Article →