Skip to content

Instantly share code, notes, and snippets.

@dbremner
Created July 15, 2017 05:04
Show Gist options
  • Save dbremner/71e547ccece3ff14d99bc990d543b9b8 to your computer and use it in GitHub Desktop.
Save dbremner/71e547ccece3ff14d99bc990d543b9b8 to your computer and use it in GitHub Desktop.
base class for KennyKerr::unique_handle (https://dx.codeplex.com)
template<class T, T invalid_value=nullptr>
struct handle_traits_base
{
using pointer = T;
inline static pointer invalid() throw()
{
return invalid_value;
}
};
//sample use
struct hdesk_traits : handle_traits_base<HDESK>
{
static void close(pointer ptr) throw()
{
CloseDesktop(ptr);
}
};
using unique_hdesk = KennyKerr::unique_handle<hdesk_traits>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment