Boost logo

Boost :

From: Michel André (michel.andre_at_[hidden])
Date: 1999-11-23 15:54:52


howard hinnant <hinnan-_at_[hidden]> wrote:
original article:http://www.egroups.com/group/boost/?start=991
> In a std::container memory can not allocated be allocated by new.
> Instead an Allocator class is passed in as a template parameter and
> optionally through the contructor as well. So internal to vector for
> example you might have code that looks like:
>
> data_ = alloc_.allocate(n);
> capacity_ = n;
> ...
> alloc_.deallocate(data_, capacity_);
>
> I was hoping to do something more like:
>
> data_.reset(data_.allocate(n), n);
>
> or something like that. Haven't had time to really work out the
details.
> But what you suggest below is really what I'm after: The ability to
use
> "auto_ptr" in the implementation. this "auto_ptr" will have to use
the
> vector's allocator to deallocate the memory. And the vector's
allocator
> needs the capacity sent to the deallocate method.
>
> Might be a dead end, don't know yet...

Ok and make the rebind struct and typedef inside as a part of your
standard allocator so it can be passed in to the auto_ptr used into
your container implementation?

/Michel

/Michel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk