Last active
December 27, 2015 17:59
-
-
Save ScatteredRay/7366353 to your computer and use it in GitHub Desktop.
deleter templates.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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