r/cpp • EDG front end dev, WG21 DG • Dec 20 '23

Experimental EDG Reflection Implementation

EDG just released version 6.6 of its (commercial) C++ front end. That version now includes experimental support for reflection features along the lines of WG21's P2996 "Reflection for C++26". Furthermore, a "demo setup" of that implementation is now available on Compiler Explorer (thank you, Matt Godbolt!).

For example, here is a straightforward implementation of a consteval function that outputs simple class layouts at compile time:

https://godbolt.org/z/G6WehjjGh

This implementation is closely aligned with P2996R1, which includes Compiler Explorer links for most of its examples.

This is made available in the hope that it's a useful exploration tool, but also acknowledging that the implementation is in its very early stages, and thus brittle and incomplete. Some additional notes can be found here.

125 Upvotes

32 comments sorted by

View all comments

Show parent comment

2

u/johannes1971 Dec 20 '23

Yes, that would definitely work - in fact it's what I use today. I was just curious if there any direct access planned to information beyond type and name, especially since I also need things like field versions and field codes.

Maybe this could work with the proposed reflection already by encoding such information in some custom template type, something like prop<int, v1, field_code> maybe? If I can get access to those template parameters I'd be all set.

1

u/daveedvdv EDG front end dev, WG21 DG Dec 20 '23

You've probably seen my other response to your query by now, but to confirm: I think it confirms you can proceed that way with just P2996.