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!
On Mon, 2004-10-18 at 20:58, Jonathan Wakely wrote:
> 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.
Yes, it should be kept in mind that the realloc trick would work only
if:
1. new_allocator was used.
2. The type is a POD type.
>
> jon
--
-Dhruv Matani.
http://www.geocities.com/dhruvbird/
The price of freedom is responsibility, but it's a bargain, because
freedom is priceless. ~ Hugh Downs