Tessil/ordered-map

It's possible provide the value() method for reverse_iterator?

portsip opened this issue · 2 comments

It's possible provide the value() method for reverse_iterator?

Thanks

Tessil commented

The following should work:

int main() {
  tsl::ordered_map<int, int> map = {{0, 2}, {1, 3}};

  for (auto it = map.rbegin(); it != map.rend(); ++it) {
    it.base().value() = 1;
  }
}
Tessil commented

I just realised in the base() documentation that The base iterator refers to the element that is next (from the std::reverse_iterator::iterator_type perspective) to the element the reverse_iterator is currently pointing to.

The above will thus not work as expected, I need to check if there's a better solution.

Something like:

(it.base() - 1).value() = 1;

would work but is very cumbersome and unintuitive.