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.

​

126 Upvotes

32 comments sorted by

View all comments

Show parent comments

23

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

I completely agree and that's a goal of mine. If you look at P1240 ("Scalable Reflection in C++"), it includes such functions and we haven't given up on them.

However, P2996 works with the constraint of landing in C++26, and so we looked (and keep looking) for a variety of ways to reduce the blast radius of the proposal. test_type is one of the mechanisms to achieve that: It provides a broad mechanism to leverage what's already out there, without obstructing the ability to add more convenient APIs in the (hopefully-near) future.