This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: vector<> can probably never grow to it's maximum size!
Dhruv Matani wrote:
Yes, but isn't it better to have the container grow somehow rather than
have it throw bad_alloc even though it can grow by whatever little it
can in situations where the memory available is low.
No, it isn't. Maybe other are willing to comment...
In my opinion, you cannot *always* consider growing 1-item-at-a-time only
because ::operator new throws. As I already told you, from the point of view
of the user, that knows nothing about memory and so on, the vector is
growing
slowly and since you are catching the exceptions he cannot know why.
In my opinion, you can only repair a single throw in low memory, when
the size
exceeds a defined limit (which depends on *many* factors, related to the
architecture, the amount of installed mem, the number of running processes,
and so on).
Paolo.