How to get the benefits of Rust Traits for runtime polymorphism in C++

Eduardo Madrid

⏱ 75 mins
intermediate
advanced
15:30-16:30, Wednesday, 25th June 2025

The traditional mechanism of untime polymorphism, in C++, is inheritance and virtual overrides, however, this mechanism requires strong commitment, including the intrusive nature of inheritance, which might be inadequate in many situations, and actually, Rust Traits are a very useful way to approach the needs of runtime polymorphism for many scenarios. Let's learn that and see if we can benefit from it natively in C++.

C++ is such an expressive language that we can incorporate a central feature of another language, Rust Traits, with just about optimal performance that may be even better than that of the normal mechanism in C++ and its native expression in Rust.

In this presentation we will start with C++ and a type erasure library to show step by step how we can transform it into the functional equivalent of Rust Traits

Eduardo Madrid

Generic Programming practitioner. Worked as team leader or tech leader at automated trading firms, the maker of Snapchat, consulting. Author of the zoo libraries, including Type Erasure and SWAR.