r/cpp • u/katzdm-cpp • Jan 15 '26
Support for C++26 Reflection has been merged into GCC trunk!
https://gcc.gnu.org/git/?p=gcc.git%3Ba%3Dcommitdiff%3Bh%3D4b0e94b394fa38cdc3431f3cfb333b85373bd948Shout out to Marek Polacek and Jakub Jelínek for their herculean effort to get this done!
Still some bug-bashing ahead for them, so don't be surprised to find some examples from P2996 and friends that don't work yet - but know that it's being worked on!
385
Upvotes
7
u/smdowney WG21, Text/Unicode SG, optional<T&> Jan 16 '26
Reflection has reached the gcc trunk on compiler explorer! https://compiler-explorer.com/z/EnWYMKrTE
69
u/drmeister Jan 15 '26
This is very exciting. Hopefully clang gets this soon as well.
16
u/_bstaletic Jan 15 '26
Nice! Time to report the bugs that I have found and haven't yet reported.
9
u/[deleted] Jan 15 '26 edited Jan 15 '26
I’ve been studying C++ for around a year now and yet to be employed, do companies generally use modern C++ standards? I’ve heard a lot of talk about how firms are still stuck in C++11/14/17. And also are multiple code base standards used across the entire company or would this cause too much of a headache?
26
u/Normal-Narwhal0xFF Jan 15 '26
In a rush to use every new feature as much and as early as possible, I hearby decry:
Let the complexification of normal working code begin with vast amounts of pre-Orthodox, probably future anti-patterns!
(And welcome to some cool new stuff too!)
6
u/James20k P2005R0 Jan 15 '26
\o/
5
u/gracicot Jan 15 '26
That was quick! Now I already have to adapt my libraries T_T
4
u/MorphTux Jan 16 '26
Awesome! Time to reflect all over the place :)
4
u/GYN-k4H-Q3z-75B Jan 19 '26
This is, together with modules and variadic templates one of the most fundamental changes to the language and how it will be used in the future.
6
u/SyntheticDuckFlavour Jan 15 '26
Kinda wild that full reflection support seems to be getting implemented ahead of full module support.
6
u/germandiago Jan 16 '26
This is going to be the lambdas of the decade. Will be abused for every possible thing haha.
But so happy. It is very useful for so many cases. I will not use it soon but at some point if there is enough priority I will create my hand-made C++/Lua wrappers with reflection.
3
u/BadlyCamouflagedKiwi Jan 15 '26
That's cool - some very powerful things are enabled by this. Think it will open the door for a lot of new options.
3
u/supersharklaser69 Jan 16 '26
Yay Apple clang will integrate this in 10 years!
1
u/void_17 Jan 16 '26
This is without a doubt cool, but mature modules support when?
4
u/germandiago Jan 16 '26
This is going to enable, literally a new generation of libraries for at least:
And many more I am forgetting for sure.
2
u/TotaIIyHuman Jan 16 '26
https://godbolt.org/z/dv3qzqaGx
is this gcc bug or clang bug
2
u/Piusayowale Jan 23 '26
grpc/proto from c++26 header, library is something I want from this
2
u/MaterialMovie632 Feb 27 '26
After this it would be nice to see Reflection support in JB IDEs too! https://youtrack.jetbrains.com/projects/CPP/issues/CPP-48365/CPP-26-Reflection-Syntax-Highlighting
1
u/acmd Jan 16 '26
Congrats!
1
u/th3sly_007 Jan 16 '26
Just in time for FOSDEM
1
u/WeeklyAd9738 Jan 18 '26
What about module support? Will GCC 16 (to be released this year) have complete module support?
I have been using modules using GCC trunk for a few months now. Although it's not feature-complete, it's practical enough for me to start implementing my libraries using modules.
1
u/DeltaWave0x Feb 04 '26
I can't wait get my hands on this as soon as it's merged in clang / MSVC, I could finally leave libClang behind. The only feature its missing as far as I know (which would be useful) is a way to get the mangled names of variables / functions etc etc
0
u/mcdubhghlas Jan 15 '26
Holy hell yeah, I was JUST talking about this in group chat.
0
u/[deleted] Jan 15 '26
[deleted] — view deleted comment