This repository was archived by the owner on Dec 26, 2023. It is now read-only.
The return type of functions that use hints should be consistent with std#138
Merged
martinus merged 2 commits intomartinus:masterfrom Dec 11, 2021
acd1034:make-functions-consistent-with-std
Merged
The return type of functions that use hints should be consistent with std#138martinus merged 2 commits intomartinus:masterfrom acd1034:make-functions-consistent-with-std
martinus merged 2 commits intomartinus:masterfrom
acd1034:make-functions-consistent-with-std
Conversation
Fixes member functions (that take hint) to return iterator instead of std::pair<iterator, bool>. Fixed member functions are: - emplace_hint - insert - try_emplace - insert_or_assign
Owner
|
Thanks @acd1034 for the contribution! This was a copy & paste error on my side, and not intentional. No idea why the standard just returns an iterator instead of the pair, but it's better to stick with that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The return types of the member functions that take a hint to insert an element are different between
robin_hood::unordered_mapandstd::unordered_map.As a result, to use
robin_hood::unordered_map, we need to do more than just replacestd::unordered_mapwithrobin_hood::unordered_map.I feel that this is preventing users from using
robot_hood::unordered_map.What I would like to do with this pull request
Make the return type of member functions of
robin_hood::unordered_mapthat take a hint to insert an element consistent withstd::unordered_map.Specific proposals
The member functions of
robin_hood::detail::Tablethat take a hint to insert an element are currently declared as follows.On the other hand, the corresponding functions of
std::unordered_mapare declared as follows.Reference: Working Draft, Standard for Programming Language C++ - ISO C++ standards committee
I would like to replace the above declaration with the one below.
Some may argue that making the above change makes it impossible to know whether an element was actually inserted or not.
If this slight difference between
robin_hood::unordered_mapandstd::unordered_mapis intentional, please abandon this proposal.Best regards.