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]

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


On Mon, 2004-10-18 at 20:11, Paolo Carlini wrote:
> Dhruv Matani wrote:
> 
> >Yes, I meant &(whatever), but these decisions can be made when we have
> >finally decided concretely on what exactly is to be done.
> >  
> >
> Would not work, because, more exactly, the type is 'const void *': that 
> argument
> is "one way", meant to provide an hint to the allocator, not to return 
> something
> to the caller.

Yes, you are right. But, I intend these changes specifically for
__mt_alloc, which is not std::allocator. There is a wrapper which can
take of these things. More specifically, this is how std::allocator can
be implemented:

template<typename T>
struct allocator : private allocator_base
{
pointer
allocate(size_type n, const void* hint = 0)
{
  return allocator_base::allocate(n);
}
};

Thus, the hint overload of the base allocator is never used!

Now, these changes take effect only when the user explicitly says:
vector<int, __mt_alloc<int> > iv;

If you use: vector<int> iv;
then you get the normal behaviour.

After all, __mt_alloc<> is an extension, and we may do whatever we want
to with it as long as we document the behaviour!


> 
> Paolo.
-- 
        -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]