-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
hash clean up #13458
hash clean up #13458
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with this change. The original implementation is completely fine https://en.cppreference.com/w/cpp/language/extending_std#Adding_template_specializations
std::hash
works for any hashmap, qHash
locks us into Qt containers.
Thank you for sharing the link:
I read it as opening a namespace as we original did is not recommend. So thats the issue we should solve. I have decided to not use a mix of std and Qt functions here to keep the code consistent with itself and compared to other places. That way readers just need to look up the Qt docs and we have to deal with only one header. Currently there is no need for std compatibity and if we decide one day to use a std container in place of QHash (which is the same anyway in Qt6) we should swap it everywhere IMHO. What do you think? |
I agree. though from what I can tell is that the warning is only there because if you're opening template <>
std::hash<PixmapKey> directly as recommended by cppreference.
I don't really see how that has a significant benefit. Let me lay out my point on why we should prefer Exceptions:
Does that make sense?
If we're okay with doing mass migrations like that sure... but I also don't see anything wrong with gradual adoption if possible. Especially in this particular case where Qt can work with both |
… and remove the std namespace block.
I have now reverted to the std::hash version and fixed it. It turns out that we need a special version with a seed parameter for full Qt compatibility: https://github.com/qt/qtbase/blob/0b0b30f7cf900ea0463f4073f0e82d014920fd1d/src/corelib/tools/qhash.h#L60 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. waiting for CI, thank you.
Instead of using the std namespace we can use qHash() for all elements.