I was wondering if there is a way to use unique_ptr with Windows HANDLEs?
I was thinking to replace the std::default_delete with s
You can create a Deleter class that will release the handle instead of calling delete().
You can see in this LINK how they've solved deleting arrays with a shared_ptr (unique_ptr also has a constructor that recieves a Delete class)
struct handle_deleter
{
void operator ()( HANDLE handle)
{ CloseHandle(p); }
};
HANDLE blah = GetSomeHandle();
unique_ptr myPointer(blah,handle_deleter);