From Jason Turner
Watch on YouTube

Summary

This episode provides a comprehensive guide to C++ unions, explaining their core properties and evolution since C++98. Jason demonstrates how unions can be anonymous, that only one member can be active at a time, and how accessing inactive members is undefined behavior. The episode covers the challenges of managing non-trivial types in unions, including memory management and proper construction/destruction, and culminates with a minimal implementation of an Optional-like class to demonstrate proper union usage patterns.

Resources

Tags