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

Conform C++ types that have a std::hash overload to Swift.Hashable #62045

Open
egorzhdan opened this issue Nov 11, 2022 · 3 comments
Open

Conform C++ types that have a std::hash overload to Swift.Hashable #62045

egorzhdan opened this issue Nov 11, 2022 · 3 comments
Labels
c++ interop Feature: Interoperability with C++ compiler The Swift compiler in itself feature A feature request or implementation

Comments

@egorzhdan
Copy link
Collaborator

We could consider synthesizing a Hashable conformance for some C++ types:

extension MyCppType : Hashable {
  func hash(into hasher: inout Hasher) {
    hasher.combine(std.hash<MyCppType>(self))
  }
}

Note that Swift.Hashable inherits from Swift.Equatable, so we'd have to conform these types to Swift.Equatable as well.

@egorzhdan egorzhdan added c++ interop Feature: Interoperability with C++ compiler The Swift compiler in itself new feature labels Nov 11, 2022
@vmk8826
Copy link

vmk8826 commented Nov 18, 2022

Can you assign this to me?

@egorzhdan
Copy link
Collaborator Author

@vmk8826 sure, please feel free to try to tackle this, and don't hesitate to ask questions.

@AnthonyLatsis AnthonyLatsis added feature A feature request or implementation and removed new feature labels Feb 24, 2023
@ktoso
Copy link
Member

ktoso commented Jul 7, 2023

Radar-ified rdar://111879435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++ compiler The Swift compiler in itself feature A feature request or implementation
Projects
None yet
Development

No branches or pull requests

4 participants