public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: mathias.hasselmann@gmx.de To: gcc-gnats@gcc.gnu.org Subject: libstdc++/5583: std::set::iterator is readonly Date: Mon, 04 Feb 2002 11:06:00 -0000 [thread overview] Message-ID: <20020203163954.25775.qmail@sources.redhat.com> (raw) >Number: 5583 >Category: libstdc++ >Synopsis: std::set::iterator is readonly >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Feb 04 11:06:04 PST 2002 >Closed-Date: >Last-Modified: >Originator: mathias.hasselmann@gmx.de >Release: 3.0.2 (and 2.95.3) >Organization: >Environment: System: Linux dali.sqx.lde 2.4.9-mosix #17 SMP Sam Sep 1 03:04:51 CEST 2001 i686 unknown Architecture: i686 <machine, os, target, libraries (multiple lines)> host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: /nfs/sam/opt/glibc/gcc-3.0.2/configure --prefix=/usr >Description: since std::set::iterator is declared as const_iterator it's impossible to write code like that: std::set<obj_t> myset; std::fill(myset.begin(), myset.end(), 42); or std::for_each(myset.begin(), myset.end(), obj_t::reset); Yes, protecting members of set protects the set from getting corrupted. _But_ if you ensure that your modification of elements of sets does _not_ change the element order (simply 'cause the element's compare operations don't consider the modification you are going to do) you really should be able to modify elements stored in a set... >How-To-Repeat: struct foo { void reset() { a = 0; }; bool operator<(const foo & other) const { return b < other.b; } int a, b; }; std::set<foo> myset; std::for_each(myset.begin(), myset.end(), std::mem_fun_ref(&foo::reset); >Fix: Heavy ugly casting to overcome const qualifiers. >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-02-04 19:06 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-02-04 11:06 mathias.hasselmann [this message] 2002-02-05 6:56 rodrigc 2002-02-05 7:26 Carlo Wood 2002-02-05 15:36 Mathias Hasselmann 2002-03-11 14:12 pme
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020203163954.25775.qmail@sources.redhat.com \ --to=mathias.hasselmann@gmx.de \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).