Summary
This episode provides a crucial follow-up to Episode 312, clarifying when to use 'static constexpr' versus 'inline constexpr'. Jason demonstrates that while 'static constexpr' remains optimal for local variables in functions (preventing unnecessary stack allocation), 'inline constexpr' is the correct choice for variables at file scope, especially in header files. Through a practical example with a large array, he shows how using 'inline' allows the linker to merge duplicate data across translation units, significantly reducing binary size.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[depr.static.constexpr]67% match