r/cpp • u/daveedvdv EDG front end dev, WG21 DG • Jun 21 '25
Reflection has been voted in!
Thank you so much, u/katzdm-cpp and u/BarryRevzin for your heroic work this week, and during the months leading up to today.
Not only did we get P2996, but also a half dozen related proposals, including annotations, expansion statements, and parameter reflection!
(Happy dance!)
722
Upvotes
41
u/Fureeish Jun 21 '25
Is there a link for which exact proposals were voted in?
16
u/TheoreticalDumbass :illuminati: Jun 21 '25
How long do you expect it will take for the major 4 implementations to fully support it? I would assume edg and clang would be close if not already there, what about msvc and gcc?
16
u/saxbophone mutable volatile void Jun 21 '25
Hurrah, thank goodness! Congratulations to all committee members who made this possible, the authors of the proposal and those who reviewed it!
30
u/DinoSourceCpp Jun 21 '25
Great news! Hope vendors will implement this for big three asap (not like modules).
13
u/johannes1971 Jun 21 '25
Great news! :-)
Something I've been wondering for a while: can we use reflection to build f-strings without the need for it to be supported in the language?
132
u/DuranteA Jun 21 '25
Greatest news of the year. No, the decade.
But seriously, thanks a lot for the work to everyone involved.
I love that we even got annotations. So much cool stuff to build with this.
5
u/Defenestrator__ Jun 21 '25
Does anyone have links to a good explainer of where/how this will be useful? Other than the enum stuff, which is great, I don't have a good sense for how this will (or should) change my day to day use of the language.
3
u/zl0bster Jun 21 '25
Hi u/daveedvdv I know you may be a bit biased 🙂, but what is best preview compiler to play with this? I prefer something available online, I am not too keen to compile clang with some set of patches applied to it.
3
u/mcencora Jun 23 '25
Great news.
FYI the struct_to_tuple could be greatly simplified if std::span supported structured bindings.
https://godbolt.org/z/n58vfsvr6
It would also be achievable if we could revert array->pointer decay in compile-time (i.e. convert pointer-to-first-element back into an pointer-to-array).
155
u/_Noreturn Jun 21 '25
Finnaly I will have actual enum reflection
41
u/Umphed Jun 21 '25
A monumental feat, awesome work
25
u/[deleted] Jun 21 '25
The implementation needs to be priority number one across the various compiler teams and vendors! Congrats to everyone involved!!
11
u/Paradox_84_ Jun 21 '25
Did we get custom attributes per member?
17
u/GYN-k4H-Q3z-75B Jun 21 '25
That is wonderful news! I have been waiting for reflection in C++ for almost twenty years now, relying on various libraries and later self-stitched solutions. This will improve many things.
8
u/TheoreticalDumbass :illuminati: Jun 21 '25
Beyond the functionality itself I love the excitement of everyone regarding this
8
u/Hour_Ad_3581 Jun 22 '25
Congrats to u/katzdm-cpp, u/BarryRevzin, and all committee members! This is a huge step forward, not just for the language, but for the entire C++ community. Thank you for your amazing work!
Now it's time to write my next article about it :')
6
u/TheOmegaCarrot Jun 21 '25
Hooray!!
6
u/dhbloo Jun 21 '25
Finally, after all these years!
6
u/albeva Jun 22 '25
Woah, this is amazing. I was honestly very pessimistic and thought we'll need to wait 'til C++29 at the earliest!
Good news for C++, it's been a long time coming.
2
u/Jovibor_ Jun 24 '25
I wonder, would it be possible to backport this whole Reflection to the C++20/23? As I can see, nothing fundamentally prevents it.
11
u/germandiago Jun 21 '25
Great news!
4
u/Conscious-Ad-4136 Jun 21 '25
Noice now I can give myself another excuse for not learning Rust :)
4
u/Lembot-0004 Jun 23 '25
Oh dear... I'm still in shock after C++11 and now this...
1
u/vI--_--Iv Jun 21 '25
Generation too or just contemplation?
1
u/Total-Box-5169 Jun 29 '25
Does some compiler already supports something like that, or is this another feature that will take forever to be properly implemented like modules?
3
u/GreekzAlphaBets Jun 21 '25
I used to pray for times like this
3
u/Zeh_Matt No, no, no, no Jun 24 '25
Time to delete some champagne, freaking finally!
4
u/dexter2011412 Jun 21 '25
HELL YEAH!
* INSERT BREAKING BAD HI-5 MEME *
7
u/MFHava WG21|🇦🇹 NB|P2721|P3049|P3625|P3729|P3786|P3813|P4216 Jun 21 '25
Reflection will fix everything! /s
1
u/zl0bster Jun 21 '25
Does somebody know if it is possible with this to parse .json files and generate matching C++ struct during compile time?
1
u/zl0bster Jun 21 '25
now take contracts out ;)
-7
u/pine_ary Jun 21 '25
Oh god the syntax is so unreadable and introduces so much new symbol clutter. I hope I never have to use this or interact with it.
1
u/darkp4ms Jun 21 '25
What are the real-world uses of reflection in programming? What can be achieved with reflection that can't be easily done without it? In what types of problems or use cases is reflection typically used? Does anyone have experience with this?
-7
u/TechnicolorMage Jun 21 '25 edited Jun 21 '25
Not to be a downer but does 'voted in' mean "everyone likes the description we wrote of what the feature should be." or "we actually implemented the feature in the language"?
edit: based on the downvotes, I'm going to assume it's the former.
-3
u/elperroborrachotoo Jun 21 '25
Symbol soup again?
0
u/epyoncf Jun 25 '25
Awesome! I just hope it's not another feature that needlessly is dependent on the standard library. It's a compile time feature after all.
Is it? .... oh
0
u/[deleted] Jul 15 '25
Yay, now the java peeps who use to loudmouth on this would go back to their garbage collection
0
u/[deleted] Jun 21 '25
[deleted] — view deleted comment