TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 227 subscribers
Post #23961 16
not be queried: https://godbolt.org/z/r19185rqr**

Which means one can not put a hypothetical `noconvert(bool)` annotation on a parameter for which one would not like implicit conversions on the python side. (Or rather, one can not find the annotation with `annotations_of()`).
The alternative is to annotate the function with an array-like list of indices for which implicit conversions are undesirable. This is a pretty error prone option that is brittle in the face of refactoring and signature changes.

I know that annotations and function parameter reflections have moved through WG21 in parallel and hence the features don't work with one another, but annotating parameters would be quite useful.

**Parameter reflections can't give us default values of the reflected parameter**

This is a can of worms. Default values need not be constant expressions, need not be consistent between declarations, and [can even "stack"](https://godbolt.org/z/Ycf9hdxxr).
However, the lack of ability to get some sort of reflection on the default value of a parameter paints us in a corner where we have to bind the same function multiple times, always wrapped in a lambda, to emulate calling a function with different number of arguments.

Here's an example: https://godbolt.org/z/Yx17T8fYh

Binding the same function multiple times creates a runtime overload set, for which pybind11 performs runtime overload resolution in a case where manual binding completely avoids the runtime overloading mechanisms.

Yes, my example with `int y = 3` parameter is very simple and avoids all the hard questions.
From where I stand, it would be enough to be able to splice a token sequence matching the default argument value.

There is a case that I don't know how I'd handle: https://godbolt.org/z/Ys1nEsY6r
But this kind of inaccessible default parameters could never be defaulted when it comes to pybind11.

## Conclusion

C++26 Reflections are amazing and the upcoming token sequences would make it even more so.
Still, there is a thing or two that I have not noticed is in planning for C++29. Specifically:

- Function parameter annotations and reflection of default values would be extremely useful. If there's one thing I'd like to get in the future, it's this one.
- Range splicers, of the form `[:...range:]` would clean up some things too.
- Template annotations as a distant 3rd for automatically generating bindings for template instantiations.

So that I don't end on a note that might look entitled, once again, a sincere thank you to everyone involved in C++ Reflections.

 

EDIT1: Fixed sloppy wording when it comes to parameter annotations.

https://redd.it/1nw39g4
@r_cpp
More from @r_cpp
  1. Oct 17, 2026"C++23 - The Complete Guide" now as Paperback C++23 - The Complete Guide is now also avail…
  2. Oct 17, 2026A quick C++ standard container overview https://meetingcpp.com/blog/items/A-quick-Cpp-stan…
  3. Oct 17, 2026The Double Headed Stack Allocator – The blog at the bottom of the sea https://blog.demofox…
  4. Oct 17, 2026Barry's C++ Blog - Generating Operator Functions https://brevzin.github.io/c++/2026/10/14/…
  5. Oct 17, 2026MSVC Build Tools Version 14.52 Release Candidate Now Available https://devblogs.microsoft.…
  6. Oct 17, 2026C++ futures part 4: What if I want an immediate on-thread std::async? https://devblogs.mic…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →