https://www.cppnow.org
---
Runtime Polymorphism with Freedom and Performance - External Polymorphism and Type Erasure - Eduardo Madrid - C++Now 2025
---
In his great presentation “Inheritance Is The Base Class of Evil,” Sean Parent clearly exposed the flaws of using inheritance and virtual overrides (subclassing) for runtime polymorphism — and solved the bulk of those problems in just 25 minutes. But what if, instead of 25 minutes, he was speaking to a C++ Now audience, with years of experience refining and applying these ideas in production? Could he have gone beyond fixing subclassing flaws — unlocking better performance, greater modeling power, and a universe of new possibilities?
Runtime polymorphism via subclassing forces a world of pains:
The Busywork: Perfectly great types must be awkwardly wrapped or restructured into the required inheritance hierarchy.
Heap Allocation and Indirection: A level of hell on its own — of forced overhead, incentivizing shared state, buffer reuse, and other hacks to mitigate their huge costs. Thread synchronization hell.
The Disempowerment of Inheritance: Subclassing only leaves inheritance as the abstraction mechanism. It’s a one-size-fits-all that seldom fits anybody; when it doesn’t fit, you’re stuck contorting and distorting your code just to make it work.
We can do so much better.
What if the alternative didn’t just fix that, but, let's say, unlocked value semantics? Even better things?
Have you heard of the Design Patterns of External Polymorphism and its refinement of Type Erasure?
Think they are too complicated and underperforming?
They have been poorly implemented at all levels, including the standard library, and their true potential has remained totally eclipsed by not realizing that rather than complicated they are very profound.
For example, I describe Type Erasure as ‘Internal External Polymorphism’. But ‘internal-external’ isn’t the only paradox that can emerge — as long as the interface can be modeled, there is the freedom to not even hold a value of the original type, but something completely different, and for very practical gains. It’s the literal erasure of the original type.
Do you want to see what happens when they’re done right?
Imagine runtime polymorphism that not only fixes the pains but gives you value semantics whenever possible. The monad of optionality, “expected,” built right in if you want them — at no extra effort. Copy-on-write semantics — applied exactly when you say it makes sense, with no performance hit. These are things that already run widely in production code.
The intersection between Design, Architecture, and Performance needed to get Type Erasure right has also surfaced new Generic Programming concepts that are relevant to a large fraction of the library.
You’ll see this is more than what has been implemented already, but how, ultimately, your imagination is the only limit.
---
Slides: https://github.com/boostcon/cppnow_pr...
think-cell develops one of the world’s leading PowerPoint applications, with C++ at the core of everything we build, from layout algorithms to deep integration with Microsoft Office. Interested in working on challenging C++ problems with real-world impact? Explore our open roles: https://www.think-cell.com/en/career/...
Eduardo Madrid
Author of open source libraries and components such as the Zoo SWAR and type-erasure framework. Prior experience as tech Lead at Snap, Inc., Fintech, including automated trading. Several times presenter at CPPCon, C++ Now, C++ London, once at C++ Munich
---
C++Now 2026 - 4th May - 8th May
C++Now is an annual onsite international C++ programming and coding conference held in Aspen, Colarado. For all C++ developers, C++ software engineers and those involved with the C++ language, CppNow provides an indepth and technical content provided by the best and brightest C++ experts of the C++ world.
Annual CppNow Conference - https://www.cppnow.org
/ cppnow
/ cppnow
/ cppnow
/ cppnow
https://mastodon.social/@cppnow
Video Sponsors: think-cell and Bloomberg
---
Videos Filmed & Edited By Bash Films: https://bashfilms.com/
YouTube Channel Managed & Optimized By Digital Medium Ltd: https://events.digital-medium.co.uk
---
#boost #cpp #cplusplus #programming #coding #softwareengineering #softwaredeveloper #code #cplusplusprogramming #cplusplustutorial #cplus #softwaredevelopment #coder #talk
In questa pagina del sito puoi guardare il video online Runtime Polymorphism with Freedom & Performance - External Polymorphism & Type Erasure - CppNow 2025 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato CppNow 17 novembre 2025, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 2,019 volte e gli è piaciuto 39 spettatori. Buona visione!