Save Big on Coursera Plus. 7,000+ courses at $160 off. Limited Time Only!
Explore the intricacies of std::variant in C++ through this comprehensive conference talk from CppNow 2021. Delve into the rationale behind std::variant as a type-safe alternative to C's union, examining typical usage patterns and implementation details. Gain insights into memory layout and runtime performance implications. Investigate key differences between std::variant and union, focusing on serialization use cases where unions excel but std::variant falls short. Discover innovative approaches to address these limitations, including Intrusive-Variant and Variant-of-Base techniques. Examine the C++ standard's stance on unions and their potential pitfalls. Learn about counterintuitive applications of std::variant, such as a simple mechanism for de-virtualization. Equip yourself with the knowledge to modernize existing low-level C-style code and deepen your understanding of variant internals in this 1 hour 31 minute presentation by experienced software developer and architect Roi Barkan.