473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

reverse_iterator to iterator

ben
If I have a reverse_iterator to an element, does the standard library
provide a way to find the iterator equivalent or do I have to roll my own?
Oct 13 '05 #1
3 7904
ben wrote:
If I have a reverse_iterator to an element, does the standard library
provide a way to find the iterator equivalent or do I have to roll my own?


i = ri.base()

john
Oct 13 '05 #2
John Harrison wrote:
ben wrote:
If I have a reverse_iterator to an element, does the standard library
provide a way to find the iterator equivalent or do I have to roll my
own?

i = ri.base()

john


Although please note that i won't be pointing at the same element as ri.
The following identity holds

&*ri == &*(ri.base() - 1)

john
Oct 13 '05 #3
ben
John Harrison wrote:
John Harrison wrote:
ben wrote:
If I have a reverse_iterator to an element, does the standard library
provide a way to find the iterator equivalent or do I have to roll my
own?


i = ri.base()

john

Although please note that i won't be pointing at the same element as ri.
The following identity holds

&*ri == &*(ri.base() - 1)

john


Great! Thanks John! I was too sleepy to pick that out from the book.

Ben
Oct 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Boogie El Aceitoso | last post by:
Hi, I'm writng a function that works an a std::string and should accept either an iterator or a reverse_iterator. How can I do this? O:-)
3
by: Eric Twietmeyer | last post by:
Hello, In playing with a reverse_iterator issue today, I realized that I could use its base() method to get at the underlying iterator. However, I realized that in the implementation shipping...
13
by: jason | last post by:
My question is regaring STL iterator/reverse_iterator. I would like to write a function which does the following int CFoo::calculate(std::vector<int>::iterator itBegin,...
3
by: Dalbosco J-F | last post by:
Hi, Sorry if this has already been answered. Given a std::list and a reverse_iterator is there a way to erase the element pointed to by the reverse_iterator via the erase method? Apparently...
3
by: noone | last post by:
string operator()(const bool clean=true) { string rv; MPEGQUEUE::reverse_iterator i=thequeue.rbegin(); MPEGQUEUE::reverse_iterator t=thequeue.rend(); while (i!=thequeue.rend()) { if...
3
by: bb | last post by:
Hi, Please could you clarify why 'implicit conversion' does not take place while assigning an iterator to reverse_iterator. However, it happens while initializing/constructing. e.g. typedef...
20
by: Jess | last post by:
Hello, I think the two reverse_iterators are the same, except that the const_ version doesn't allow me to change the value pointed to by the iterators. However, I have a program that works for...
4
by: * Tong * | last post by:
Hi, Simple question, how to get a reverse_iterator? As you can see from the following code, I managed to answer the first half of the question myself, but can't figure out the second half: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.