Skip to content
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

Fix hash_value template resolution #180

Merged
merged 3 commits into from
Feb 15, 2024

Conversation

Krzmbrzl
Copy link
Collaborator

@Krzmbrzl Krzmbrzl commented Feb 6, 2024

Fixes #179

@Krzmbrzl Krzmbrzl changed the title Fix test case not actually doing any testing Fix hash_value template resolution Feb 8, 2024
seed = begin->hash_value();
else {
using sequant_boost::hash_value;
[[maybe_unused]] std::size_t seed = hash_value(*begin);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a functional change here where previously the hash-value of *begin would be computed, but the result would be discarded and the original seed would be left in an uninitialized state. This seemed like a bug to me, so I changed it but you'll probably want to double-check that this was not intended behavior after all 👀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, late night coding, ignored what the compiler was trying to tell me ... 5ff476d

By bringing the Boost hash_value functions into the SeQuant namespace,
some instantiations of the hash_value function resolved to the general
Boost functions instead of using the specializations provided by
SeQuant. In particular, expression objects with a hash_value member
function would simply be hashed via a generic hash_range implementation
(as every expression is also a range) instead of using the template
specialization that delegates to the (memoizing) hash member function.

This issue is resolved by not importing the functions from the Boost
namespace but instead keeping two specializations in the SeQuant
namespace that either resolve to the member function (if present) or the
generic Boost function (if the object does not have a hash member
function and a suitable overload on Boost's side is found).
Copy link
Member

@evaleev evaleev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, looks good ... now that it turns out we need Boost 1.81 (#182) massive cleanup is possible, but to be done elsewhere

@evaleev evaleev merged commit e8aab56 into ValeevGroup:master Feb 15, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in tensor hash test case
2 participants