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

Gabriel Dos Reis gdr@cs.tamu.edu
Mon Oct 18 18:50:00 GMT 2004


Jonathan Wakely <cow@compsoc.man.ac.uk> writes:

| On Mon, Oct 18, 2004 at 06:59:28PM +0530, Dhruv Matani wrote:
| 
| > 4. The post on google also hints at changing the behaviour of
| > new_allocator<> for in-built types so that copying is not required if
| > realloc is used. This is probably a not so related issue, so clubbing
| > these would probably not be right.
| 
| But it also explains why realloc() is not possible for C++ objects.
| You need something other than realloc, so that if the existing block
| can't be grown then allocation fails. You must not allocate a new block
| and move the contents.

I think I disagree with your comments.

I consider the allocate() with hint as something implementable in
current C++.  I tried it on linux-based systems.  The big thing is to
have knowledge about cookies malloc/realloc interaction.

-- Gaby



More information about the Libstdc++ mailing list