Add iterator traits #3
Open
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.
Incorporating @jan-moeller's suggestion from #2.
There are a few caveats with this: I changed the
value_typetotypename Element::value_type. Theelementwrapper is used for custom comparisons inside aneternal::map, but the dereference operator returns the encapsulatedstd::pair. This means that STL algorithms will get thestd::pairand call its operators, e.g. when comparing. This may be fine for your use case, but it's different from theeternalsort order, which is based on the key exclusively and never on the value. This only matters when you useeternal::map/hash_mapas a multimap (i.e. with duplicate keys).An alternative could be to derive
elementfromstd::pairinstead of wrapping it. We can't usestd::pairdirectly because its comparison operators aren'tconstexprin C++11, theirstd::swapspecialization isn'tconstexpruntil C++20, and forelement_hash, we need a custom hashing comparator.