This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/24061] New: Documentation in /tr1/hashtable proposes possibly misleading change
- From: "atavory at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Sep 2005 23:59:08 -0000
- Subject: [Bug c++/24061] New: Documentation in /tr1/hashtable proposes possibly misleading change
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
/tr1/hashtable lines 1318-132 documents hashtable::erase(const_iterator i)
It states:
"The return type should be const_iterator,
and it should return the iterator following the one we've erased.
That would simplify range erase."
However, if erase would return an iterator, range-erase would not work the way
the comment suggests. The comment (probably) refers to code like the following
(attempting to erase values whose key is larger than 20):
for(typename T::iterator i = t.begin(); i != t.end();)
if(i->first > 20)
i = t.erase(i); // (*)
else
++i;
This looks simple, but it probably won't work. The line marked by (*) might
resize the container, which will rehash/reposition all values. The iterator i
might point to values already accessed, or might have skipped passt values not
yet accessed, or both. tr1 is correct: t.erase(i) cannot return any meaningful
iterator.
--
Summary: Documentation in /tr1/hashtable proposes possibly
misleading change
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: atavory at gmail dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24061