public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "igodard at pacbell dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/16875] Fails to compile: STL container of const pointer to X
Date: Wed, 06 Oct 2004 22:04:00 -0000	[thread overview]
Message-ID: <20041006220432.2487.qmail@sourceware.org> (raw)
In-Reply-To: <20040804124119.16875.loose@astron.nl>


------- Additional Comments From igodard at pacbell dot net  2004-10-06 22:04 -------
I've reopened this PR after looking at #16875 (which I can't re-open, although 
I've cross-posted this note there). The basic argument to reject that bug was 
that putting consts in a standard collection is non-sensical, because the 
collections re-organize themselves and you can't do that with a const element 
type. This seems shortsighted, as my application shows (the test case I 
submitted was simplified from the actual use).

In my application, I have a number of data values (the number is statically 
known) that I need to put into a data structure and subsequently do various 
kinds of searches on them. The searchers are not to be permitted to change the 
values once they are in the structure. Using "int" as the element and "vector" 
as the collection (mine is more complicated), the code looks something like:

     vector<const int> v;
     #define count = 5
     v.reserve(count);
     void init() { for (int i = 0; i < count; ++i) {int j; j << cin;
         v.push_back(j);}} // push_back works because it constructs, not copies
     void use() {  for_each(v.begin(), v.end(), something()); }

That is, I want to be able to use the whole algorithm and collection 
machinery without re-inventing the wheel, on a standard collection and that 
collection's contents that will be immutable once it is built. This seems a 
reasonable need to me; do you differ and still think it is non-sensical?

Ivan


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16875


  parent reply	other threads:[~2004-10-06 22:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-04 12:41 [Bug c++/16875] New: " loose at astron dot nl
2004-08-04 12:46 ` [Bug c++/16875] " loose at astron dot nl
2004-08-05  2:07 ` [Bug libstdc++/16875] " pinskia at gcc dot gnu dot org
2004-08-05  8:03 ` gdr at integrable-solutions dot net
2004-10-06 20:08 ` pinskia at gcc dot gnu dot org
2004-10-06 20:32 ` pinskia at gcc dot gnu dot org
2004-10-06 22:04 ` igodard at pacbell dot net [this message]
2004-10-07  1:23 ` pinskia at gcc dot gnu dot org
2004-10-07  2:22 ` igodard at pacbell dot net
2004-10-07  2:50 ` pinskia at gcc dot gnu dot org
2004-10-07  7:32 ` loose at astron dot nl

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=20041006220432.2487.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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: link
Be 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).