The following code would make a callback via template:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <iostream> template <typename F> void call(F func) { func(); } void print() { std::cout << __FUNCTION__ << "()" << std::endl; } int main() { call(print); } |
No comments:
Post a Comment