• Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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

Share this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement