I mean that if I have a const collection object then no matter what
iterators I have I will not be able to erase any element. But if I
have a non-const collection object then why am I not allowed to erase
its elements with a const iterator? After all I could as well take new
non-const begin and advance it until it is equal to the const iterator
and use such iterator for erasure.
Adam Badura
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
You are right, this will be fixed in the next standard, C++0x.
Bo Persson
The simple answer is: Because the C++ standard says so. And it says so
because nobody pushed for a different erase member functions.
BTW: The upcoming C++ standard actually fixes this.
Cheers!
SG
Perfectly right - therefore the Standard Library has fixed this
awful state by accepting LWG issue:
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#180
as a defect and applying the proposed resolution published in
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2350.pdf
The current working draft has these changes implemented.
HTH & Greetings from Bremen,
Daniel Kr=FCgler
This is a known problem. In other words, an iterator has three different
interfaces:
1. Marking a position in a sequence.
2. Read access to the underlying element.
3. Write access to the underlying element.
For erasing, only the first interface is actually necessary, but there is=
no
distinct type common to both "iterator" and "const_iterator" that provide=
s
this interface, instead the containers all want the "iterator" as
parameter.
Uli
--
Sator Laser GmbH
Gesch=C3=A4ftsf=C3=BChrer: Thorsten F=C3=B6cking, Amtsgericht Hamburg HR =
B62 932