This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/5583] std::set::iterator is readonly
- From: "erikhaugen at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Nov 2003 00:13:42 -0000
- Subject: [Bug libstdc++/5583] std::set::iterator is readonly
- References: <20020204110604.5583.mathias.hasselmann@gmx.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From erikhaugen at yahoo dot com 2003-11-26 00:13 -------
(In reply to comment #5)
> State-Changed-From-To: feedback->closed
> State-Changed-Why: LWG Defect Report #103 has resulted in a change to the C++
> Standard: std::set::iterator is /required/ to be read-only.
> So, this is now definitely not a bug. :-)
>
> Your example of directed edges doesn't really work: you
> didn't specify how "edge_t" is supposed to be ordered, but
> assuming that you define an operator< which examines the
> 'weight' member, then you /still/ can't change the weight,
> because that would be changing the ordering! It's right
> back to the original problem...
No, the example actually does work just fine. The missing operator< should
only compare u and v. The poster made this very clear: "Obviously edges of a
directed weighted exclusively are distinguished by their vertices. Obviously it
would be nonsense to allow edgessets like {(1,2,3),(1,2,3)} or {(1,2,3),
(1,2,inf)}." Your assumption that operator< would examine the weight is
certainly incorrect.
This is a fine example of why you would want to be able to modify a value in a
set, but I guess as of the defect report you'll have to pick a different data
structure.
-Erik Haugen <erikhaugen@yahoo.com>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5583