Two months ago I published “the
hidden compile-time cost of C++26 reflection”, where I
measured what including <meta> and doing some basic
reflection actually costs per translation unit. If you haven’t
read it, start there – this post builds directly on top of it.
That article used a prerelease GCC 16 snapshot. Since then, GCC 16 has been officially released1 and is now widely available, which seemed like a good excuse to revisit the topic with a more realistic example: enum-to-string conversion.
Enum-to-string is the “hello world” of reflection – but it’s also genuinely useful in real projects, for things like logging, serialization, debugging, and so on. If you adopt reflection in a real codebase, it might be the first thing you’ll write.