Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C++ Programming

doubt on erasing the first element of a vector with reverse_iterator


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

On 30 Maj, 09:12, wolverine <kiran.ha@gmail.com> wrote:

> 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 Wikstrm

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc