From -174230353307037907
X-Google-Thread: f78e5,27c2a088314ec0a9
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news2.google.com!proxad.net!news2.telebyte.nl!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: dhruvbird@gmx.net ("Dhruv Matani")
Newsgroups: comp.std.c++
Subject: Re: should std::vector<> exponential growth rate be followed	strictly in times of low availabe memory.
Date: Wed, 27 Oct 2004 03:43:46 GMT
Lines: 48
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <pan.2004.10.27.02.38.48.35649@gmx.net>
References: <pan.2004.10.21.16.46.37.514542@gmx.net>	<417E434E.5000209@bubblescope.net>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: news.demon.co.uk 1098848634 23249 158.152.254.254 (27 Oct 2004 03:43:54 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Wed, 27 Oct 2004 03:43:54 +0000 (UTC)
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Pan/0.13.3 (That cat's something I can't explain)
X-Orig-X-Trace: news.uni-berlin.de h6rYHu87gZCTxYt7Mr1qtA8d9Yld9EJUg91oTjTpSESEwqDEgc
X-Virus-Scanned: by amavisd-new at cs.mu.OZ.AU
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i9R3hlrt002899;
	Wed, 27 Oct 2004 13:43:47 +1000 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-Delivered-To: std-c++@ucar.edu
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
Xref: g2news1.google.com comp.std.c++:3200

On Tue, 26 Oct 2004 21:18:18 +0000, chris wrote:

> Dhruv Matani wrote:
>> Hello,
>> 	I recently had a discussion about whether the exponential growth policy
>> for std::vector<> should be followed strictly no matter what.
>> 
>> The case I'm looking at is something like this:
>> 
>> const int init_sz = 1.2 * 1024 * 1024 * 1024; // 1.2GB.
>> std::vector<char> cv(init_sz);
>> cv.push_back('a');
>> 
> ..
>> Assume that the growth factor is 2.
> ..
>> What my argument is that an implementations should be allowed to deviate 
>> slightly from the standard to prevent useless exception like the above 
>> from being thrown. It should be clear that from the user's point of view,
>> what he sees is that he already has 1.2GB of data, and he is trying to add
>> 1-byte to that! Why for any reason should that fail? Assume that the user
>> is in no position to use reserve. Obviously if that is considered, then
>> the whole post is useless ;-)
> If your only aim is to remain standards compliant, then one option would 
> be to reduce what you claim the minimum growth factor will be in tight 
> memory situations, say to 1.05. If you can't extend the vector by at 
> least 5% then is it really worth doing it? In this way you could perform 
> better in low memory situations but still be standard compliant.
> 
> If you wanted to be really sick, you could claim that your minimum 
> growth factor is 1+5*10^(-20), which would mean that on a system with a 
> 64-bit address space you would still never have to expand by more than 
> 1, but I believe you could still claim to be standards compliant ;)

Yes, but it would obviously be a nonsense implementation as you have
mentioned. I'm looking more at making it allowable by the standard in
such low memory situations to deviate from the exponential growth
policy.

Reagrds,
-Dhruv.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



