1

The normal way to convert from reverse to forward iterator is

std::prev(r_it.base())

Is this valid when r_it is the same as rend()? If not, how to safely convert any reverse iterator to forward iterator, where result of rend() converts to result of end()

Neil Kirk
  • 21,327
  • 9
  • 53
  • 91
  • At worst case, if you detect this condition, you just use `begin()`. – jxh Jul 28 '14 at 15:27
  • When the container is random access: `container.begin() + (rev_it - container.rbegin())`, this would convert `rbegin` in `begin`, `rend` in `end` and in between too, you could use `std::advance` for other container instead of `+`, noting the performance cost. – NetVipeC Jul 28 '14 at 15:28

0 Answers0