Skip to content

Add support for enum <--> string conversion #3264

@daljit46

Description

@daljit46

There are a lot of parts of our codebase, especially the CLI, that rely on strings for configuration and option handling, where using enums would be much nicer.
C++ unfortunately (and astoundingly) doesn't have builtin support for enum <--> string conversion. C++26 added reflection, which will finally allows to build such a basic utility but it'll be a few years until our codebase can make use of that.
In #3258, I made use of magic_enum for this purpose. It works very well and I think we should consider adopting this, perhaps wrapping the library in our own interface. An alternative is enchantum, which has the added benefit of lower compilation times due to template instantitations (which is something we should consider given that our compilation times are not exactly excellent).
AFAIK, both libraries are relying on compiler specific behaviour to achieve this, but all major compilers (GCC, Clang and MSVC) are supported.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions