This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

vector<> can probably never grow to it's maximum size!


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]