-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Access member descriptor from pointer-to-member #78
Comments
Hey there 👋, There is currently no provision for a field descriptor lookup given a pointer to a member, however, one can be added if it's going to be useful, which it seems to be 👍. |
To provide some background: I am trying to build a serialization framework where types can be automatically serialized via reflection (as fallback), but the user can still customize the serialization of a specific type by using template specialization. It would be nice if attributes (or more generally the descriptor) can still be accessed from this customized serialization function. My first idea for implementing this would be by using Note that there is absolutely no hurry. I am just toying around with a pet project. |
Ah, that makes sense. Have you considered Something like template <typename T, typename C, T C::*P>
auto find_field_impl() {
return refl::util::find_one(field_descriptors_of<C>{}, [](auto m) { return m.pointer == P; });
} |
Sorry for the late reply. I missed The example looks good! Just noticed a typo in line 11, A bit sad that the additional type traits are necessary, but I guess there are already a lot of custom type traits in the library. |
I've been wondering: is there an easy way to access the descriptor of a specific member directly, rather than looping over all members.
Something like:
The text was updated successfully, but these errors were encountered: