Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-09-02 16:00:47


Gregory Colvin <gregory.colvin_at_[hidden]> writes:

>> Also, if shared_ptr only needs to allocate at construction time (I'm
>> not sure of this) we can avoid storing the allocator at all.
>
> Then how to deallocate?

Using the custom deleter?

>>> I'm reeling from the implication that the following is undefined
>>> behavior for non-POD T:
>>>
>>> T* p = (T*)malloc(sizeof T);
>>>
>>> Are you sure?
>>
>> Nope. 3.8/5 shows that I'm wrong.
>
> That's a relief.
>
>> It still doesn't make any sense to
>> return a T* from allocate since normally with a non-singular T* p,
>> either p == 0 or *p refers to a constructed T.
>
> The idea was that Allocator<T>::pointer might be a proxy type
> that cannot be converted to void* and back, so allocate() must
> return and construct() must take an Allocator<T>::pointer rather
> than a void*.

Wow, creepy.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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