Power BI Fundamentals - Create visualizations and dashboards from scratch
Get 35% Off CFI Certifications - Code CFI35
Overview
Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
Explore type erasure as one of C++'s most powerful yet underrated idioms in this 56-minute conference talk from CppCon 2025. Discover how type erasure enables runtime polymorphism without inheritance while maintaining C++'s static safety guarantees, drawing parallels to duck typing found in dynamic languages. Learn how the C++ Standard Library leverages type erasure in essential tools like std::function and std::shared_ptr to store, dispatch, and manage heterogeneous objects with minimal friction. Build understanding through hands-on exploration as you examine a simplified version of std::function crafted from scratch and investigate how std::shared_ptr uses type erasure to maintain type safety while enabling polymorphic deletion. Uncover the hidden performance costs, memory allocations, and vtable machinery that accompany type-erased constructs through profiling and real-world scenarios. Evaluate when type erasure justifies its trade-offs versus alternatives like templates or CRTP (Curiously Recurring Template Pattern). Gain practical intuition for wielding type erasure judiciously to write cleaner, more flexible, and performance-aware modern C++ code while understanding its inner workings and appropriate use cases.
Syllabus
Duck Typing, the C++ Way: How Type Erasure Bends the Rules - Sarthak Sehgal - CppCon 2025
Taught by
CppCon