How to convert an enum to string in C++

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • metalang99

    Full-blown preprocessor metaprogramming

  • There are also other approaches. Macro variants making use of `__VA_ARGS__` would be probably the best trade-off. If you want a slightly more ergonomic syntax, something like Metalang99 [1] will help (and the author even wrote a post about this exact subject [2]). Codegen is another option which may work better than other options depending on the situation and exact implementation strategy. And there is always the Reflection TS [3], which may or may not be incorporated to C++26...

    [1] https://github.com/Hirrolot/metalang99

    [2] https://hirrolot.github.io/posts/pretty-printable-enumeratio...

    [3] https://en.cppreference.com/w/cpp/experimental/reflect

  • winresult

    Debug-friendly rust types/codes for windows results

  • https://github.com/MaulingMonkey/winresult/

    Another project: thindx. Bindings for d3dcompiler + d3d9 + xinput have a lot of enums and flags:

    • 50 results in 49 files for flags!: https://github.com/search?q=repo%3AMaulingMonkey%2Fthindx%20...

    • 77 results in 69 files for enumish!: https://github.com/search?q=repo%3AMaulingMonkey%2Fthindx+en...

    • I still do things by hand somtimes, for reasons that elude my recollection: https://github.com/MaulingMonkey/thindx/blob/127d75f9de91f73...

    And these are baby numbers compared to an actual professional gamedev codebase. Attention to detail makes me fairly comfortable with this much hand-generated nonsense in my one man show, but bugs still crop up... and there are people I would dread handing maintainence of such a project over to that I've worked with in a professional capacity, who simply do not care to exercise the same level of care as I do when editing such stuff.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • thindx

    Thin DirectX wrappers for Rust.

  • https://github.com/MaulingMonkey/winresult/

    Another project: thindx. Bindings for d3dcompiler + d3d9 + xinput have a lot of enums and flags:

    • 50 results in 49 files for flags!: https://github.com/search?q=repo%3AMaulingMonkey%2Fthindx%20...

    • 77 results in 69 files for enumish!: https://github.com/search?q=repo%3AMaulingMonkey%2Fthindx+en...

    • I still do things by hand somtimes, for reasons that elude my recollection: https://github.com/MaulingMonkey/thindx/blob/127d75f9de91f73...

    And these are baby numbers compared to an actual professional gamedev codebase. Attention to detail makes me fairly comfortable with this much hand-generated nonsense in my one man show, but bugs still crop up... and there are people I would dread handing maintainence of such a project over to that I've worked with in a professional capacity, who simply do not care to exercise the same level of care as I do when editing such stuff.

  • Better Enums

    C++ compile-time enum to string, iteration, in a single header file

  • I really like better_enums instead of magic_enums. There’s no limit on enum size with it: http://aantron.github.io/better-enums/

    It was heavily used at a former employer of mine, so definitely a solid production-ready solution.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Inside boost::unordered_flat_map

    11 projects | /r/cpp | 18 Nov 2022
  • Using Jolt with flecs & Dear ImGui: Game Physics Introspection

    4 projects | dev.to | 17 Apr 2024
  • STB: Single-file public domain libraries for C/C++

    4 projects | news.ycombinator.com | 6 Jan 2024
  • Factor is faster than Zig

    11 projects | news.ycombinator.com | 10 Nov 2023
  • Enforcing Memory Safety?

    3 projects | /r/cpp | 7 Jun 2023