-
Notifications
You must be signed in to change notification settings - Fork 99
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
Hashable should take type index into account #131
Comments
Why is it the problem? There are hash collisions anyways. After matching the hashes of two values any algorithm which uses hashes should to compare for equality. Variants with different active alternatives are not equal. Runtime overhead imposed by hash-combining of the value's hash and of the the (excessive) hash of its index is permanent otherwise. It is hardly desirable. |
I sure the probability of |
I open this ticket mainly because I read the updates on http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0088r3.html
and http://en.cppreference.com/w/cpp/utility/variant/hash
the Boost.Variant impl. does the same, too. |
Anyways hash combining every time for any alternative type is permanent runtime overhead. But |
Hashing a variant should take the type index /
.which()
into account in addition to the underlying hashvariant/include/mapbox/variant.hpp
Lines 1002 to 1011 in 02bd1ac
variant/include/mapbox/variant.hpp
Lines 536 to 544 in 02bd1ac
Why? Because of the edge case where the underlying hash is the same but the type index is not.
The text was updated successfully, but these errors were encountered: