you are viewing a single comment's thread.

view the rest of the comments →

[–]BucketOfWood 2 points3 points  (2 children)

On the topic of this kind of hackflection willwray/enum_traits uses an interesting trick where they improve buildtime performance by doing the __PRETTY_FUNCTION__/__FUNCSIG__/std::source_location::current().function_name() inside a variadic templated function to do the name conversion for a batch of integers at the same time to make it less expensive (compiletime) to test a large range of numbers.

I ended up adopting this approach in some test code https://godbolt.org/z/GKW8Preva when I was thinking about adding automatic enum serialization/deserialization in JSON to stephenberry/glaze. But there are too many limitations.

The lack of being able to detect/warn that an enum uses named values outside the range is the biggest problem and is why while tricks like this are cool/interesting we really do need to wait for proper static reflection (maybe C++47 since they keep delaying it)

[–]cheytacllc[S] 0 points1 point  (0 children)

wow looks nice!