-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full blown reflection for aggregate structs in clang #532
Conversation
I'm not sure if you guys use clang, but check out this black magic: tests/reflection_test/reflection_test.cpp This branch enables real reflection, no macros, no user code, for clang. If a What are your thoughts on using |
This works in Xcode 15 and later versions of clang, but I'm seeing if I can get it to work with Xcode 14.2, which is used for these actions. |
This is awesome, I really hope that the c++ committee makes this as a standard, that is reflection of members.
Looking at the docs: https://clang.llvm.org/docs/LanguageExtensions.html#builtin-dump-struct it is said to be for debugging purposes, so I would suggest to mention it in docs. Can we put an Would it be possible to implement to_tuple with tuple_cat ? |
Yeah, it looks like we'll be getting real reflection in C++26 (see Herb Sutter's blog), but in the meantime this could be nice and we could invisibly replace this behavior with C++26 reflection when available.
Great idea!
No, |
This seems great, guys. Especially since it can be "invisibly replaced with C++26 reflection." I've been following the standards committee on the reflection proposals, and it all looks promising. I'm not sure I'll have time to experiment with this clang-specific addition in the next couple days, so I'll have to leave it to you two. Great find. |
This reverts commit bacd069.
This uses clang's __builtin_dump_struct to enable fully featured (no macros, no user code) reflection for aggregate initializable structs. Only works on clang, no gcc or msvc.