[Bug libstdc++/5583] std::set::iterator is readonly
erikhaugen at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Wed Nov 26 00:13:00 GMT 2003
------- 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
More information about the Gcc-bugs
mailing list