Type Safety
C-era enums, unions, and raw pointers leave behind too many type safety pitfalls—implicit conversions, undefined behavior, null pointer dereferences... Modern C++ provides a suite of tools to plug these holes. In this chapter, we explore how enum class puts an end to the nightmare of implicit enum conversions, how strong typedefs prevent parameter mix-ups, how variant safely replaces unions, how optional elegantly expresses "maybe no value," and how any achieves type erasure when needed.