refactor: simpler type check in Acts::Any#4993
refactor: simpler type check in Acts::Any#4993timadye wants to merge 8 commits intoacts-project:mainfrom
Conversation
|
|
Thanks @timadye. I think this is exactly what we're had in This exactly exhibits the problem: the pointers will point at different addresses in different shared libraries and the check then returns false, identifying them as separate types. The pointer comparison in the assignment operator is likely a bug I think. |
|
Sorry, I didn't see that you'd tried this before. I think I see how yours might work. The pattern is the same. In each case you are relying on a In that case, you rely on However, according to cppreference, the only things guaranteed to match are comparing libstdc++'s
I think it does both for speed, and so it mostly works even if RTTI isn't available. I think we could do something similar by caching a pointer to the I can try that... |
|
We just need to make sure that this then actually works, also in @wdconinc's case. I fear that all of the guarantees around
|
|
I tried to reproduce @wdconinc's issue with https://godbolt.org/z/ev74rP8GY . This has a In all cases, it worked fine if the types were the same, and correctly threw an exception if they were different. Maybe I missed some combination, but I tried lots! I have so-far only tried with my implementation here, but expect it would work just as well with #4968. |
|
@timadye That's interesting. I know @asalzburger had originally reported the issue with just using the pointer, but I remember that was in the depths of the python bindings and specifically on macOS and AppleClang. I'm not sure if he would be able to reproduce it at this point. |
|
The updated |
|
|
|
|
|
@timadye can you unpack for me what this means in terms of conclusion? |
|
Sorry, those two examples were actually working as expected. I was asking for a different class out of
Let me keep hunting... |
|
I have now tried three types to store in the
In all cases, it works correctly with no |
|
|
I updated to the latest |



A simpler alternative to #4968.
I think this is equivalent, in that both use a unique static variable in a member function templated on the contained type. This PR just replaces the hashed type name with a pointer to
Handler.Also adds a missing include.
@paulgessinger