Matus,For run time reflection needs there is a lot to like in your implementation. My main interest is using reflected info in injection statements at compile time, i.e. within consteval functions that generate code. It would be nice to play around with this reflection implementation in that context as well.To that end I cleaned up and updated my old string-injection* implementation:(Example usages here: https://github.com/drec357/llvm-project/blob/stringinjection/_stringinj/inj01.cpp)And I merged it with your project, into here:
Referring to your mirror01.cpp example, it would be nice to be able to use the combination of reflection and injection to do something like the following:```consteval void inject_name_and_nextdayval(std::string_view n) {
auto d = string_to_enum<weekdays>(n);
__injf("static const weekdays {} = {};", "dummy", 3);
}
struct next_day_of {
consteval {
using namespace std::experimental::mirror;
for_each(get_enumerators(mirror(weekdays)), [](auto mo) {
inject_name_and_nextdayval(get_name(mo));
});
}
};
```(By the way, how does one put this merged project onto a separate compiler-explorer instance? Can anyone assist with that?)
However the above fails due to the usual inability to constant evaluate the necessary expressions. It might yet be possible with other TMP iteration techniques, though a simpler iteration interface will be nice. I suspect `template for` may still be needed for using refections in injection statements and for other compile-time tasks, I will try to add that feature to the above repositories in the next few days to see what that adds.But let me know if you try it out and find a nicer way to do this.