From: Howard Hinnant (hinnant_at_[hidden])
Date: 1999-11-23 15:33:09
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;
I was hoping to do something more like:
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...
Michel André wrote on 11/23/99 3:15 PM
>> This is just a scoped_ptr with a capacity thrown in that it can hand back
>> to Allocator::deallocate. Note that scoped_ptr may be useful as is for
>> use in node based standard containers because it passes "1" in
>> Allocator::deallocate. Again, haven't actually implemented a standard
>> container in terms of one of these. Just exploring the possibility.
>I really don't see the use of this but maybe you could enlighten me?
>Couldnt the standard containers be implemented with an scoped_array or
>an auto_ptr with an array deallocator?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk