Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2004-12-29 06:06:23


>> is it possible to use smart_ptr with handles ( e.g. HWND, HBRUSH, HDC,
>> etc )?
>
> Policy based smart pointer easily handle HANDLE ;))

I believe shared_ptr with a custom deleter can work with handles (which are
really just pointers in disguise), probably something like:

void handle_deleter(void* p)
{
::CloseHandle((HANDLE)p);
}

shared_ptr<void> phandle(my_handle, &handle_deleter);

Regards,

John.


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