Iterator to reverse_iterator?
From the stl, is it possible to get a reverse_iterator from a regular iterator? Couldn't find anything mentioning this, I would guess not but I'm not sure.
Quote:Original post by DeadXorAlive
From the stl, is it possible to get a reverse_iterator from a regular iterator? Couldn't find anything mentioning this, I would guess not but I'm not sure.
Reverse iterators have an explicit conversion from regular iterators. The semantics are defined as follows:
&*(reverse_iterator(i)) == &*(i - 1).
CM
int main(){ std::vector<int> v; std::vector<int>::iterator e = v.end(); std::vector<int>::reverse_iterator f(e);}
Ah thanks a bunch, that's simple. Is the reverse also possible? Thank you. I'm still trying to grok iterator_traits and all that, there's much more goodness to it all than I thought.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement