This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
vector<> can probably never grow to it's maximum size!
- From: Dhruv Matani <dhruvbird at gmx dot net>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: 17 Oct 2004 09:29:48 +0530
- Subject: vector<> can probably never grow to it's maximum size!
- Organization:
Hello,
I would like to discuss an issue which deals with vector's memory
management. Consider a 16 machine.
Here, max_size() would typically be say: ((2^16)-1)/sizeof(_Tp). Now,
consider that the current size is max_size()/2. If I want to add say 3
more elements, the vector to get space for totally max_size() elements,
and will fail because operator new will probably fail because of such a
large request. Can't we have the vector settle for a slightly smaller
return from the allocator at the expense of not sticking to the standard
strictly about the exponential increase policy?
--
-Dhruv Matani.
http://www.geocities.com/dhruvbird/
The price of freedom is responsibility, but it's a bargain, because
freedom is priceless. ~ Hugh Downs