Cost of enum-to-string: C++26 reflection vs. the old ways

(vittorioromeo.com)

17 points | by sagacity 4 hours ago ago

4 comments

  • HarHarVeryFunny 9 minutes ago

    No doubt reflection has been built with other use cases in mind, but it sure would have been nice just to have std::to_string(enum)

  • w4rh4wk5 27 minutes ago

    I've been wondering about debug-ability of code using reflection. X-Macros are quite annoying to step through in most debuggers, though possible. While the code in the first example is evaluated fully at compile-time, how would you approach debugging it?

  • sagacity 4 hours ago

    Oof, that first example (the idiomatic C++26 way) looks so foreign if you're mostly used to C++11.

    • ginko 24 minutes ago

      Is it? I'm mostly used to (pre-)C++11 and the only unusual operators I see are ^^T (which I presume accesses the metadata info of T) and [:e:] (which I assume somehow casts the enumerator metadata 'e' to a constant value of T).

      And template for but I assume that's like inline for like in zig.