Skip to content

Instantly share code, notes, and snippets.

@ScatteredRay
Last active December 27, 2015 17:59
Show Gist options
  • Save ScatteredRay/7366353 to your computer and use it in GitHub Desktop.
Save ScatteredRay/7366353 to your computer and use it in GitHub Desktop.
deleter templates.
template <typename T, void (*f)(T*)>
class delete_fun
{
public:
void operator()(T* obj) const
{
f(obj);
}
};
struct Foo
{
};
void testFree(Foo* foo)
{
}
void test()
{
delete_fun<Foo, testFree> fun;
// Is there any way I can make it `delete_fun<testFree> fun;`
fun(new Foo());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment