Closed riidefi closed 9 months ago
No, I am not familiar, but it looks very cool. I will certainly take a look.
For these kind of purposes we have Literals as well, but being able to support enums in this way is a very cool thing.
https://github.com/getml/reflect-cpp/blob/main/docs/literals.md
Again, thank you very much for your input. This is a great issue.
So, I have taken a closer look at the library you have mentioned and my enthusiasm for it has somewhat receded.
The problem with it that it uses compiler-specific and non-standard hacks. It is very cool and I am impressed to see that it is possible. However, these kind of hacks are not enterprise-grade code.
reflect-cpp aims to be standard-compliant and enterprise-grade and therefore I wouldn't want to rely on such methods.
Moreover, reflect-cpp already provides a fully standard-compliant alternative, namely rfl::Literal
.
The good news is that the C++ reflection standard promises official support for exactly these kind of things. Once that is out, I would be only too happy to include this in reflect-cpp as well, because it is indeed very cool.
However, until that time I don't think there is a way forward, so I am closing an issue. If you, or somebody else, can come up with a standard-compliant way to support this, feel free to reopen the issue and continue the debate. I would only be to happy to be able to support this.
@riidefi , so I have experimented with this a bit more and I have now found a way to do do this in a way that I don't think is too hacky. So this is now supported.
I am not sure if you are familiar with the
magic_enum
library, but this is the behavior I would expect. Some extension ifmagic_enum
is detected would also be fine.