Boost logo

Boost Users :

From: Thorsten Ottosen (tottosen_at_[hidden])
Date: 2006-04-03 09:41:17


me22 wrote:

> On 4/1/06, Marco Correia <mvc_at_[hidden]> wrote:
>
>> B* obj = my_alloc<D>::allocate(1);
>> obj = new (obj) B();
>> container.insert(obj);
>>
>> My problem is that when an object is removed from the container, I
have to
>> explicitely deallocate it from my allocator, but the static info was
lost, so
>> I cannot do
>>
>> my_alloc<?>::dealloc
>> I've asked in boost irc channel, and someone told me ptr_* boost
libraries
>> solve this problem, is this correct?
>>
>
>
> I don't think that the ptr_ ones will, but shared_ptr allows you to
> specify a custom deleter at construction, which seems to be to be just
> what you need.

Well, if you need to keep the exact type around, you can use typeid().
But you need that both with shared_ptr and ptr_vector.

With ptr_vector, you can plug your allocator into new_clone() and
delete_clone().

-Thorsten


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net