Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
-
None
Description
Q_ENUM exposes a limited form of introspection to enums, including int/string conversions and element counts.
it would be great to have some high-level functions (e.g. templated free functions) to access enums within a few single helper function rather than going through the `QMetaEnum` API, which is quite clunky
MyEnum { Null, }; MyEnum null{}; QMetaEnum::fromType<MyEnum>()::valueToKey(null); // returns NULL
there are some shortcuts, e.g. QTest::Internal::toString has an enum specialisation. but it would be great to have those functions in a publicly available place.
my non-qt implementation for smart enums can possibly help as inspiration for a interface: https://github.com/timblechmann/nova_enums?tab=readme-ov-file#example