eternal
eternal copied to clipboard
Add iterator traits
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.