Summary
In this episode, Jason explores the concept of multiple dispatch (also known as multimethods), which allows function calls to be dynamically dispatched based on the runtime types of multiple arguments. He contrasts this with single dispatch polymorphism (using virtual functions), where dispatching is based only on the type of the object a method is called on. The episode demonstrates two C++ approaches to implement multiple dispatch: a manual approach using dynamic_cast with inheritance hierarchies, which is error-prone and verbose, and a more elegant approach using std::variant and std::visit that can handle multiple types without heap allocations.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[class.virtual]58% match -
[facet.ctype.char.virtuals]58% match -
[temp.res.general]53% match -
[variant.visit]40% match