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

(vittorioromeo.com)

18 points | by sagacity 4 hours ago

4 comments

  • HarHarVeryFunny 13 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 30 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.
    • randusername 4 minutes ago
      I was a fool to assume that the same forces shaping the ugliness of C++ syntax would not also be at work in C++ 26.
    • ginko 28 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.

  • jesgran 3 hours ago
    [dead]