Reflection for C++26

Overall reception

  • Many are enthusiastic that static reflection is finally close to standardization; some call it long overdue.
  • Others are wary of added complexity and syntax they find “atrocious,” worried C++ keeps growing harder to learn and implement.
  • Several see it mainly as a library-building tool rather than something most application code will use directly.

What static reflection enables

  • Frequently cited use cases:
    • Serialization/JSON (structs to/from JSON with minimal boilerplate).
    • Enum introspection (names ↔ values) without hacks like magic_enum.
    • Command-line parsing from an options struct.
    • “Universal” formatters, printers, and hashers that walk members.
    • Struct↔tuple conversion, generic tuple/variant helpers, struct-of-arrays vs array-of-structs transforms.
    • Generic “property systems,” scripting bindings, test/benchmark discovery.
  • Some note it can be a basis for building runtime reflection libraries.

Performance, compile-times, and bloat

  • Static reflection is compile-time only; no extra RTTI required.
  • Strong expectation that enum reflection via the proposal is dramatically faster than current template tricks that brute-force over value ranges and parse function names.
  • Others warn that reflection can still cause code and binary bloat (e.g., many generated strings, heavy templates), and that naive designs can be proportional to source size.
  • There is concern about compilation time for “non-trivial” reflection-heavy code, though early clang implementations are reported as fast; GCC/MSVC are still unknown.

Language design, complexity, and process

  • Some argue that requiring preview implementations before standardization is essential, citing past missteps.
  • Ongoing debate: C++ as “patchwork” vs. a coherent multi-paradigm language; whether subsets are realistically enforceable in large teams.
  • Critiques that big features (modules, coroutines, initializer lists, universal references) were slow to arrive or feel half-baked.
  • Reflection syntax (notably the ^ operator) is seen by some as inelegant or overkill for what “should be rare.”

Runtime reflection, Qt, and attributes

  • Reflection is viewed as making it easier to implement dynamic reflection and potentially reduce reliance on tools like Qt’s moc, though it cannot fully replace dynamic facilities.
  • Some examples show Qt-like property grids and scripting bridges built on reflection.
  • The current paper does not include richer annotations/attributes for things like “don’t serialize this” or custom field names; a separate proposal is mentioned for that and its status is unclear.