KEMBAR78
Remove non-Standard `<hash_map>` and `<hash_set>` by StephanTLavavej · Pull Request #5764 · microsoft/STL · GitHub
Skip to content

Conversation

@StephanTLavavej
Copy link
Member

Overview

This permanently removes our non-Standard <hash_map> and <hash_set> headers, which were superseded by C++11 <unordered_map> and <unordered_set>.

Fixes #5228.

Eliminating this code removes unnecessary complexity from this fiendishly complex library. For users, it removes ways to write non-portable code. For library implementers, it reduces our maintenance burden, making it easier for us to reason about the remaining Standard code.

In July 2015, VS 2015 shipped with impossible-to-ignore "hard deprecations", where we emitted compiler errors telling users that "<hash_map> is deprecated and will be REMOVED." With 10 years of notice, it's finally time to deliver as promised.

Commits

  • Delete <hash_map> and <hash_set>.
  • Remove stdext::hash_value/hash_compare.
  • Update the escape hatch for inclusion assumptions.
    • This was introduced in VS 2022 17.4 by <xhash> should avoid including <xstring> #2996, which made <unordered_map> and <unordered_set> avoid including most of <string>. We can retain this escape hatch cheaply, but I believe we should rename it now. _LEGACY_CODE_ASSUMES_XHASH_INCLUDES_XSTRING follows our usual naming (even though it drags in a bit more). That will avoid confusion (why is a project silencing stdext hash deprecation warnings when stdext hash is gone?) and prompt affected users to take another look and hopefully fix their inclusion assumptions where possible.
  • _Standard is always true now.
  • Remove tests/std coverage.
  • Delete tests/tr1 coverage.
  • Drop tests/tr1 comments.

@StephanTLavavej StephanTLavavej requested a review from a team as a code owner October 4, 2025 22:10
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Oct 4, 2025
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Oct 4, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Final Review in STL Code Reviews Oct 4, 2025
@StephanTLavavej
Copy link
Member Author

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

Copy link
Member

@davidmrdavid davidmrdavid left a comment

Choose a reason for hiding this comment

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

🦑

const _Nodeptr _Bucket_lo = _Vec._Mypair._Myval2._Myfirst[_Bucket << 1]._Ptr;
for (;;) {
// Search backwards to maintain sorted [_Bucket_lo, _Bucket_hi] when !_Standard
// Search backwards for historical reasons
Copy link
Member

Choose a reason for hiding this comment

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

I feel a future maintainer/contributor will eventually wonder what's this history. Would love to know the details.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Search backwards for historical reasons
// Search backwards for historical reasons
// Feel free to make it search forward, now that the reasons have disappeared

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not actually sure if changing the search direction would be an observable behavioral change. git blame will allow future maintainers to perform programmer-archaeology.

Copy link
Member

Choose a reason for hiding this comment

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

I won't insist, but I do feel that just stating 'for historical reasons' may lead to the conclusion that this behavior must say as-is, which isn't necessary. But as you say - it might not lead to an observable change so perhaps it doesn't matter. Do feel free to merge, it's got my approval :) .

@StephanTLavavej StephanTLavavej moved this from Final Review to Merging in STL Code Reviews Oct 9, 2025
@StephanTLavavej StephanTLavavej merged commit ce071fc into microsoft:main Oct 10, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews Oct 10, 2025
@StephanTLavavej StephanTLavavej deleted the no-hash branch October 10, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Something can be improved

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

<hash_set|hash_map>: Add opt-out to the stdext namespace

3 participants