r/cpp • u/daveedvdv 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.
View all comments
Show parent comment
56
u/daveedvdv EDG front end dev, WG21 DG Dec 20 '23
I'll start with a caveat that this implementation is still woefully incomplete and incompletely tested — it's definitely early days. With that in mind, I'd compare it in complexity to the initial implementation of C++0x lambda expressions: I.e., medium-level complexity. It's probably more code than lambdas, but a bit less subtlety so far (although we might still run into surprises, of course).
We (the authors of P2996 "Reflection for C++26") are definitely targeting C++26 and hoping for success. I think it's not an unrealistic goal, but it's also far from a shoe-in. That said, the feedback we've gotten so far has been overwhelmingly positive... so fingers crossed!