-
Notifications
You must be signed in to change notification settings - Fork 448
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
Raw pointer properties don't seem to work #52
Comments
I've done a test using the latest version of RTTR (master) and that has the same issue. |
I found the reason for this issue, but I have to think about how to fix it now easily. |
I've investigated a bit more and I've found a fix. I'm not sure if it's okay with you, but I'll make it locally so I can continue. So, the problem seems to be that there's two uses of pointers in RTTR:
In the first case, we don't actually want to update the pointer itself, rather we want to update the value of thing the pointer points to, which explains the current copy behavior when setting pointers. In this case, the pointer should logically be considered a const pointer to a non-const object, even though it's not. In the second case, we do want to update the pointer itself; the pointer is the value. So, the fix I've made is as follows. First, I've modified the current specialization of
This allows us to select the correct specialization to use, depending on the desired behaviour. Next, I've updated property_wrapper_member_object.h line 161 becomes:
and property_wrapper_object.h line 151 becomes:
(note the addition of the This change allows the 'regular' specialization of This seems to work for me and all unit tests still pass. Do you think this could be a good way to fix it? I'll use raw pointers if I want to 😎 (in this case it's for some high performance stuff). |
In working with pointers more, we've noticed that support for pointers just seems broken in general. At the very least, polymorphic pointer assignment (assign pointer-to-derived-type to pointer-of-base-type) and pointer comparison don't work. There may be other issues with pointers we just haven't run into yet. We have local fixes for both of them. Should I open new bugs for these things or is it OK for this bug to serve as an assortment of pointer problems? |
@rovarma The following specialization is made to be used only for the property policy bind_as_ptr
Your specialization with the const Template argument, should not be necessary,
So I need to make the specialization only be called with the policy. Yes, please report any bugs you found and when you found one, open up a new issue for every bug. |
No problem. Hope you had a good holiday. The reason why the specialization is called even without the policy is because in the regular Changing the specialization from Of course, if the intent is really that the I'll leave it up to you to decide which fix you prefer :) EDIT: I've opened bugs for the other two issues we've encountered: #55 #56 |
I'm trying to register a class with raw pointer properties (i.e. no smart pointer stuff) and RTTR (0.9.5) does not seem to handle it correctly. The issue seems to be that pointers are being assigned by value. This manifests itself in two different ways:
Both are pretty unexpected, but looking at the code this seems to be by design, which seems pretty odd. I'm building on Windows using VS2015, for x64 bit.
Minimal repro case:
Am I doing something obviously wrong?
The text was updated successfully, but these errors were encountered: