By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,423 Members | 1,294 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,423 IT Pros & Developers. It's quick & easy.

doubt on erasing the first element of a vector with reverse_iterator

P: n/a
Hi,
I have read that to erase an element from a vector with
reverse_iterator we have to use
-- vector.erase( (++reverseItr).base()) -- But assuming i have to
delete the first element of the vector ( zeroth index), would this
result in undefined behavior. My thinking is like, since the
reverseItr is already pointing to the first element of the vector,
when we increment it and try to get the base, will this work ?

Thanks in advance
Kiran

May 30 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 30 Maj, 09:12, wolverine <kiran.ha...@gmail.comwrote:
Hi,
I have read that to erase an element from a vector with
reverse_iterator we have to use
-- vector.erase( (++reverseItr).base()) -- But assuming i have to
delete the first element of the vector ( zeroth index), would this
result in undefined behavior. My thinking is like, since the
reverseItr is already pointing to the first element of the vector,
when we increment it and try to get the base, will this work ?
Yes, since v.rend().base() == v.begin().

--
Erik Wikström

May 30 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.