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

Support heterogeneous C++26 overloads #35

Closed
iwubcode opened this issue Sep 29, 2022 · 3 comments
Closed

Support heterogeneous C++26 overloads #35

iwubcode opened this issue Sep 29, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@iwubcode
Copy link

iwubcode commented Sep 29, 2022

Would you be interested in updating unordered_dense to support heterogeneous overloads outlined in the paper: cplusplus/papers#1037 (which seems like it is a go for C++26)

It can be helpful when trying to do a find on an object that the map doesn't directly support but can be looked up...but still requiring an insert of the real type if it doesn't exist.


Contrived example

Today:

ankerl::unordered_dense::map<std::string, int, StringHash, std::equal_to<>> map;
auto it = map.find(std::string_view{"hello world"});
if (it == map.end())
{
  auto [ new_it, success ] = map.emplace(std::string{"hello world"}, 42);
  it = new_it
}
// do something with it

Future:

ankerl::unordered_dense::map<std::string, int, StringHash, std::equal_to<>> map;
auto [ it, success ] = map.try_emplace(std::string_view{"hello world"}, 42);
// do something with it
@iwubcode iwubcode added the enhancement New feature or request label Sep 29, 2022
@martinus
Copy link
Owner

Hi, certainly sounds like a good idea. Direct link to the API summary of P2364R3: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2363r3.html#summary

@martinus
Copy link
Owner

martinus commented Oct 3, 2022

Implemented in #36, will create release v1.4.0

@martinus martinus closed this as completed Oct 3, 2022
@iwubcode
Copy link
Author

iwubcode commented Oct 3, 2022

Thank you so much @martinus !! Really loving your project. Appreciate all the hard work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants