From: Edward Diener on
In the two forms of vector::erase:

iterator erase(iterator position);
iterator erase(iterator first, iterator last);

can the 'iterator' mentioned be a vector::const_iterator,
vector::reverse_iterator, or vector::const_reverse_iterator as well as a
vector::iterator ?

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Mathias Gaunard on
On 7 f�v, 23:01, Edward Diener <eldiener_no_spam_h...(a)tropicsoft.com>
wrote:
> In the two forms of vector::erase:
>
> iterator erase(iterator position);
> iterator erase(iterator first, iterator last);
>
> can the 'iterator' mentioned be a vector::const_iterator,
> vector::reverse_iterator, or vector::const_reverse_iterator as well as a
> vector::iterator ?

No, since it must be an "iterator", and those types aren't convertible
to it.
You should, however, be able to extract the iterator out of the
reverse_iterator using .base().


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: achp on
On 8 фев, 02:01, Edward Diener <eldiener_no_spam_h...(a)tropicsoft.com>
wrote:
> In the two forms of vector::erase:
>
> iterator erase(iterator position);
> iterator erase(iterator first, iterator last);
>
> can the 'iterator' mentioned be a vector::const_iterator,
> vector::reverse_iterator, or vector::const_reverse_iterator as well as a
> vector::iterator ?

No, it must be an iterator. You can also get iterator from
reverse_iterator by calling base().

However, there is no portable way to use a constant iterator here.
That may seem logical; the idea of constant iterator is that it cannot
be used to alter the container, even though you need a non-const
container object to call erase().


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Daniel Krügler on
On 8 Feb., 00:01, Edward Diener <eldiener_no_spam_h...(a)tropicsoft.com>
wrote:
> In the two forms of vector::erase:
>
> iterator erase(iterator position);
> iterator erase(iterator first, iterator last);
>
> can the 'iterator' mentioned be a vector::const_iterator,
> vector::reverse_iterator, or vector::const_reverse_iterator as well as a
> vector::iterator ?

Additional to the comments from Mathias and achp
it is worth noting that from C++0x on you can indeed
use vector::const_iterator as function arguments
here, because they are just "position values", which
are not affected by the iterator capability to
modify the referenced data.

HTH & Greetings from Bremen,

Daniel Kr�gler



--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Edward Diener on
Daniel Kr�gler wrote:
> On 8 Feb., 00:01, Edward Diener <eldiener_no_spam_h...(a)tropicsoft.com>
> wrote:
>> In the two forms of vector::erase:
>>
>> iterator erase(iterator position);
>> iterator erase(iterator first, iterator last);
>>
>> can the 'iterator' mentioned be a vector::const_iterator,
>> vector::reverse_iterator, or vector::const_reverse_iterator as well as a
>> vector::iterator ?
>
> Additional to the comments from Mathias and achp
> it is worth noting that from C++0x on you can indeed
> use vector::const_iterator as function arguments
> here, because they are just "position values", which
> are not affected by the iterator capability to
> modify the referenced data.

Are you saying that in C++0x a const_iterator means that one can not
modify the value to which the iterator refers, as opposed to modifying
the sequence itself ? In that case will the sequences change, so that
possible sequence member functions which modify the sequence, and use an
iterator to specify a position in the sequence, will now have
const_iterator versions of the modifying member functions ( such as
vector::erase ) ?


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]