From Jason Turner
Watch on YouTube

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.

Resources

Tags