Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2002-11-18 07:53:27


On Sunday, November 17, 2002, at 10:01 AM, Peter Dimov wrote:

> From: "David Abrahams" <dave_at_[hidden]>
>>> I haven't encountered a need to inspect the deleter yet... what
> interface
>>> are you suggesting?
>>
>> How about:
>>
>> // attempt to extract a deleter of type D
>> D* d = boost::get_deleter<D>(p);
>> if (d)
>> {
>> // that was the deleter type used.
>> }

Why is it important that the type of the deleter be able to vary at
runtime? It seems to me that this problem could be more elegantly and
efficiently solved if the shared_ptr's deleter type were fixed at
compile time.

> BTW, the deleter is not required to have an address. For example, the
> current shared_ptr implementation can easily be made to optimize out
> checked_deleter<Y> instances.

A compressed_pair-style optimization will return an address (reference)
even for members whose space has been optimized away.

-Howard


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