Reference invalidation after applying reverse_iterator on a custom made iterator

reverse_iterator does not work with so-called “stashing iterators”, iterators that returns references to things within themselves. The operator* of reverse_iterator makes a copy of the wrapped iterator, decrements it, and returns the result of dereferencing the copy. Hence, if dereferencing iterator returns a reference to something inside itself, the reference will become dangling. An attempt … Read more