A C++17 library for runtime polymorphism using type erasure, offering non-intrusive interfaces, value semantics, and customizable storage and dispatch.
Dyno is a C++ library that implements runtime polymorphism through type erasure, similar to Rust trait objects or Go interfaces. It allows defining dynamic interfaces that types can fulfill non-intrusively, without inheritance, heap allocation, or sacrificing value semantics. It solves common drawbacks of C++ virtual functions by offering customizable storage and dispatch mechanisms.
C++ developers building systems requiring runtime polymorphism with performance constraints, extensibility, or compatibility with value-based APIs. It's particularly useful for library authors and those working on performance-sensitive code where traditional inheritance is limiting.
Dyno provides greater flexibility and performance than C++'s built-in virtual functions by decoupling interface from implementation. Developers choose it for its non-intrusive design, control over storage and dispatch, and ability to optimize polymorphic calls beyond what compilers can achieve with vtables.
Runtime polymorphism done right
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows third-party and standard library types like std::vector to fulfill interfaces without modification, using parametric concept maps as shown in the README.
Polymorphic objects can be passed, copied, and stored naturally, eliminating the need for pointers or clone methods, and integrating seamlessly with C++ value-based APIs.
Provides policies like sbo_storage for small buffer optimization, enabling allocation-free polymorphism for objects under a configurable size, as demonstrated in the storage customization examples.
Vtable policies allow inlining hot functions or splitting vtables, reducing indirection and potentially outperforming traditional virtual calls, with selectors for fine-grained control.
The README explicitly disclaims any stability guarantees, marking it as experimental and risky for long-term projects due to potential breaking changes.
Requires integrating multiple Boost dependencies (e.g., Hana, CallableTraits) and understanding a custom DSL for interfaces, adding overhead compared to standard C++ features.
Leverages advanced C++17 features like variable templates and type erasure concepts, which may be unfamiliar to developers used to inheritance-based polymorphism.