Skip to content

Type Safety

C-era enums, unions, and raw pointers leave behind too many type safety pitfalls—implicit conversions, undefined behavior (UB), 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-typed typedefs prevent parameter mix-ups, how variant safely replaces unions, how optional elegantly expresses "possibly no value," and how any achieves type erasure when needed.

Chapter Contents

v0.7.1-1-gb1e27bb · b1e27bb · 2026-07-05