Skip to content

Berkeley: dynamic_cast From Scratch

Photo of Bryce Adelstein Lelbach
Hosted By
Bryce Adelstein L.
Berkeley: dynamic_cast From Scratch

Details

For the next two months, many of our speakers will be honing their presentations for CppCon 2017 (https://cppcon.org). (Sept 24–29 in Bellevue, WA — get your tickets now!) We'll kick off our run-up to CppCon with a presentation from Arthur O'Dwyer on dynamic_cast.

This session will introduce you to the rules by which C++ class objects are translated into memory layouts. We'll move from simple structures to polymorphic class types, then onward to multiple and virtual inheritance. We'll discuss the anatomy of a virtual method call, the difference between `static_cast` and `reinterpret_cast`, and what's contained in a vtable besides function pointers. The climax will be a complete implementation of C++'s built-in `dynamic_cast`, using our own hand-crafted artisanal run-time type information (RTTI). We'll see that the way `dynamic_cast` thinks about the class hierarchy is slightly different from the way we're used to drawing it; and that `dynamic_cast` is expensive enough that sometimes we can find cheaper ways to ask an object for its type!

Attendees will incidentally be exposed to several features of the modern C++ language, including type traits and the `final` qualifier.

This session will mostly be talking about the Itanium C++ ABI, which is the standard on Linux and OS X systems; the MSVC ABI will be mentioned but not dwelt upon.

Arthur O'Dwyer worked for many years at Green Hills Software, making the world's most optimizing C and C++ compilers. Now he works at Nominum in San Francisco, making DNS software. He is the showrunner of the Bay Area C++ meetup and has spoken at CppCon for the past three years.

Join us after the talk at for drinks and food at a local Berkeley restaurant!

Photo of Cpp Bay Area: C++ Programming In and Around Silicon Valley group
Cpp Bay Area: C++ Programming In and Around Silicon Valley
See more events