# Iterator to reverse_iterator?

This topic is 4322 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
Quote:
 Original post by DeadXorAliveFrom 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

##### Share on other sites
int main(){	std::vector<int> v;	std::vector<int>::iterator e = v.end();	std::vector<int>::reverse_iterator f(e);}

##### Share on other sites
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.

e = f.base();

##### Share on other sites
Fruny thanks. This stuff makes me happy. [smile]
I'll stop spamming the forum now.