
29 Dec
2004
29 Dec
'04
11:06 a.m.
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.