Hi David,

On Sun, Dec 5, 2021 at 6:40 PM David Rector <davrec@gmail.com> wrote:
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: 

And I merged it with your project, into here:
Nice!
 

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));
    });
  }
};
I think we'll get to code-splicing eventually, but to do it properly we need to gather some usage experience.
 
```
(By the way, how does one put this merged project onto a separate compiler-explorer instance? Can anyone assist with that?)

I recently learned that it is just a matter of creating a ticket on github and providing the necessary info :)

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.

The first thing that I want to try out with code injection is to implement some form of identifier splicing from metaobjects, but I want to finish the TS implementation first.

--Matus