From Jason Turner
Watch on YouTube

Summary

This episode compares two techniques for handling multiple types in a callable object: inheriting from multiple lambdas (as shown in previous episodes) versus using C++14's generic lambdas. Jason demonstrates both approaches using the example of processing std::variant collections, highlighting their respective advantages and disadvantages. While lambda inheritance allows for distinct handlers for each type, generic lambdas offer the advantage of shared state among all type handlers. The episode also incorporates C++17's if constexpr to elegantly handle type dispatch in the generic lambda approach, demonstrating how different C++ features can be combined to create clean, flexible visitor implementations.

Resources

Tags