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

Specialize TfHashAppend for std::shared_ptr and std::unique_ptr #2304

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

nvmkuruc
Copy link
Collaborator

@nvmkuruc nvmkuruc commented Feb 21, 2023

Description of Change(s)

TfHash and VtHash may utilize ADL of hash_value for their hashing implementations. As usage of boost::hash_value is being phased out, it's possible for other hash_value implementations to be picked up. Specifically, while testing the removal of boost::hash_value from pxr/base/vt/hash.h (#2176), stdext::hash_value was getting discovered on certain Windows builds when hashing std::shared_ptr. boost::hash_value was previously providing the std::shared_ptr specialization for VtHash but with #2176 VtHash prefers TfHash and TfHash may resolve to the stdext::hash_value implementation.

This PR provides an implementation of TfHashAppend for std::shared_ptr and std::unique_ptr which hash their underlying pointers and takes precedence over hash_value.

While providing a TfHashAppend implementation for std::shared_ptr and std::unique_ptr precludes hash_value ADL, it's worth noting that for user code using VtHash or TfHash, other types may be affected by this and additional specializations may be required.

This should not affect the specialization of TfHashAppend for std::shared_ptr<_Untyped> used in pxr/usd/ar which hashes the pointed to value instead of the pointer.

Fixes Issue(s)

  • I have verified that all unit tests pass with the proposed changes
  • I have submitted a signed Contributor License Agreement

@tallytalwar
Copy link
Contributor

Filed as internal issue #USD-8044

@pixar-oss pixar-oss merged commit f274221 into PixarAnimationStudios:dev Mar 2, 2023
@nvmkuruc nvmkuruc deleted the tfptrhash branch March 2, 2023 19:38
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.

3 participants