Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-11-17 13:04:19


"Peter Dimov" <pdimov_at_[hidden]> writes:

> 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.
>> }
>
> 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.

Okay then:

bool found = boost::has_deleter<D>(p);
if (found)
{
    D& d = boost::get_deleter<D>(p);
}

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

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