Reflection
Reflection was THE topic of CppCon 2025… aside from AI. It dominated every discussion. It was in every keynote. It was mentioned in the Fireside chat panel. There were multiple other talks on it. And it isn’t even available yet!
Note
Even though it is not widely available yet, you can still play with it with some compiler branches on godbolt e.g. https://godbolt.org/z/MasKrrdhv
C++26’s hot new feature is Reflection and I am so excited for it. It looks so powerful and in Herb Sutter’s words, “this is a feature that will take over 10 years to figure out how to use”. Or in Hana Dusíková’s words, “Whole new language”.
Practical Reflection
This was a fantastic talk from Barry Revzin. If you haven’t heard of Barry before, have a look at the features that went into C++23. A large proportion of recent C++ features have come from Barry. Or at least that’s how it feels when I look at the papers for C++20 and C++23. He seems to be one of the most prolific contributors to the language currently.
This whole talk was a very practical example of how you can use C++ reflection to write a class called SoAVector<T> and the idea is that you can define your data type, T, and give it to SoAVector<>, and it will reflect over T and create a structure of
arrays data layout for your type. This is amazing.
One of the big parts of C++26 which complements reflection is the new concept of “annotations”. Annotations are like attributes (e.g. [[nodiscard]]) except that are spelled with [[=MyCustomType]] (the difference is that there is an = there). You can
use any type as your annotation which means that you can create custom annotations! As an Unreal dev this just made me think of creating annotations like…
[[= UProperty<FEditAnywhere, FCategory<"Color">>]]Warning
I have no idea if this would be valid syntax, or even if this is how you might want to do this, but I hope it is enough to get the point across
This just seems like reflection in C++26 will make Unreal Header Tool (the part of Unreal that generates all of Unreal’s runtime reflection code) completely redundant… or at least mostly redundant. This is quite an exciting prospect as an Unreal developer. Unreal’s reflection system is a necessary evil right now that lets us do really powerful things, but C++26 reflection sounds like it will be much more powerful.
If you want to learn more, Barry has a great blog post on the same topic as this talk here
Reflection: C++’s Decade-Defining Rocket Engine
This was Herb’s keynote, and I think the title shows his excitement for the feature.
In this keynote, Herb essentially convinced me that I wasn’t getting carried away with all my ideas for reflection. It is just that exciting. And he came with claims of it delivering faster compile times since everything can be written as a constexpr function rather than abusing the C++ type system like you do with template meta programming.
Note
Most standard libraries do not implement type traits as templates because templates are super slow to instantiate. They use compiler intrinsics instead for speed. Constexpr functions, on the other hand, are much quicker for the compiler to evaluate. And so if you can define type traits in terms of reflection and constexpr functions, you should see compile time speed ups compared to type traits defined using template meta programming.
Herb gave a few examples of things you might want to do with reflection such as constructing classes using JSON objects in a file at compile time. Along with some other examples and things to think about… such as the possibility of taking C’s title of being the “Lingua Franca” of programming languages. It was all just very exciting stuff!