A Month of Writing Reflections-based Code: What have I learned? -- Boris Staletić
This post chronicles a month-long experiment using C++26 reflections to automate the generation of pybind11 bindings, blending the promise of modern metaprogramming with real-world complexity. It offers a candid look at what worked beautifully, what fell short, and what future language features could make reflection-driven automation even more powerful.
A Month of Writing Reflections-based Code: What have I learned?
by Boris Staletić
From the article:
I have been trying to automate writing my own pybind11 binding code with the help of C++26 reflections, as implemented by clang-p2996.
There were moments where things went smoothly, but also moments where I missed a feature or two from the world of reflections. Then there is also accidental complexity caused by pybind11 having features which are, at the very least, not friendly for generic binding generation.
Before I begin, a massive thanks to Barry Revzin, Daveed Vandevoorde, Dan Katz, Adam Lach and whoever else worked on bringing Reflections to C++.
Smooth sailing
What we got from the set of reflections papers is awesome. Here's an example of what can be achieved quite easily:
https://godbolt.org/z/jaxT8Ebjf
With some 20 lines of reflections, we can generate bindings that cover:
free functions (though not overload sets of free functions - more on that later)
structs/classes with
a default constructor
member functions
data members, though always writable from python
You can also see how this easily generalizes to all other kinds of
py_class.def_meow(...). Almost... Since C++ does not have "properties" in the python sense,def_property_meowwill need special care.

When you pass an overloaded function like
The new Constexpr Debugger available in the first CLion 2025.3 EAP build allows you to stay in the compiler’s world and see what really happens – by stepping through evaluation, inspecting values, and confirming which if constexpr branch fired. Using it helps you understand exactly what the compiler is doing and fix issues faster.
A long-delayed dream finally came true: after years of near-misses and lessons learned (“better to be invited than sent”), I made it to CppCon—and it was bigger, louder, and more inspiring than I imagined. In this recap I share the vibe of the week, five standout talks and ideas, a few notes from my own session, and links to recordings as they appear.
Structured binding is a C++17 feature that allows you to bind multiple variables to the elements of a structured object, such as a tuple or struct. This can make your code more concise and easier to read, especially when working with complex data structures. On this blog, we already covered this functionality, but we’ll talk about some good C++26 additions and real code use cases.