How to get member uvalue of Derived class, from Base* #88
-
Hello, I have a vector of Base* and using resolve_type, i can successfully get members of Derived classes but when checking with In any case, thank you so much for this library! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
After some investigation, it looks like |
Beta Was this translation helpful? Give feedback.
-
Hello and thanks for your interest in this library! So, yes, you made a good research. We don't have enough dynamic functions to manage your case. We can't using instance's poly info in functions like To resolve your problem, I think we should have an additional
Where I believe with this, you can cast your base instance to the most derived class and call whatever you want. I'm going to think about it. And I will be glad to any suggestions! |
Beta Was this translation helpful? Give feedback.
-
Thank you for taking time to comment! So, with this additional ...
class_type klass = resolve_type(base_ptr);
uvalue var = klass.get_member("var").get(ucast(base_ptr, klass));
... Honestly, i would be more than happy if i could just get a To give you more context, what I'm trying to achieve is to get pointers to members of component classes that derive from a base |
Beta Was this translation helpful? Give feedback.
-
Added new It returns a pointer of the most derived type, which can be used as an instance for member access. See a little example with comments here: https://github.com/BlackMATov/meta.hpp/blob/main/develop/untests/meta_issues/github_discussion_88.cpp I believe it should help! :-) |
Beta Was this translation helpful? Give feedback.
-
Wow! Thank you so much for implementing this so quickly! It works as expected now! Thanks! |
Beta Was this translation helpful? Give feedback.
Added new
meta_poly_ptr
method toMETA_HPP_ENABLE_POLY_INFO
macro.It returns a pointer of the most derived type, which can be used as an instance for member access. See a little example with comments here: https://github.com/BlackMATov/meta.hpp/blob/main/develop/untests/meta_issues/github_discussion_88.cpp
I believe it should help! :-)