vector<> can probably never grow to it's maximum size!
Dhruv Matani
dhruvbird@gmx.net
Sun Oct 17 04:03:00 GMT 2004
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
More information about the Libstdc++
mailing list