Iterator to reverse_iterator?

Started by
4 comments, last by DeadXorAlive 17 years, 12 months ago
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.
Advertisement
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);}
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
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();
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Fruny thanks. This stuff makes me happy. [smile]
I'll stop spamming the forum now.

This topic is closed to new replies.

Advertisement