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

Add iterator traits #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add iterator traits #3

wants to merge 2 commits into from

Conversation

kkaefer
Copy link
Collaborator

@kkaefer kkaefer commented Apr 7, 2020

Incorporating @jan-moeller's suggestion from #2.

There are a few caveats with this: I changed the value_type to typename Element::value_type. The element wrapper is used for custom comparisons inside an eternal::map, but the dereference operator returns the encapsulated std::pair. This means that STL algorithms will get the std::pair and call its operators, e.g. when comparing. This may be fine for your use case, but it's different from the eternal sort order, which is based on the key exclusively and never on the value. This only matters when you use eternal::map/hash_map as a multimap (i.e. with duplicate keys).

An alternative could be to derive element from std::pair instead of wrapping it. We can't use std::pair directly because its comparison operators aren't constexpr in C++11, their std::swap specialization isn't constexpr until C++20, and for element_hash, we need a custom hashing comparator.

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.

2 participants