From Jason Turner
Watch on YouTube

Summary

This episode explores std::unreachable, a new feature in C++23 that explicitly invokes undefined behavior to optimize impossible code paths. Jason demonstrates how the compiler can use this function to eliminate code branches that should never be executed, contrasting it with traditional error handling approaches like exceptions, exit calls, and assertions. The episode also covers proper switch statement design, emphasizing the importance of handling all enumeration cases explicitly rather than using default cases.

Resources

Tags