Is it possible to deduce a non-type function pointer type template argument (function pointer) from a function argument?
template <void(*fptr)()>
void test(void(*fp)()) { fp(); }
to call this function I must explicitly declare the function template parameter:
test<somefunc>(somefunc);
I know I could also do it this way:
template <void(*fptr)()>
void test() { fp(); }
test<somefunc>();
But I am just wondering if It is possible to do this way:
template <void(*fptr)()>
void test() { fp(); }
test(somefunc);
Is it possible to declare in such a way that the compilier (GCC 4.7) will deduce from the function arguments?
Thanks alot in advance, been really wondering how to do this.
-Bryan
Bryan, that seems to be quite eccentric mix of low-level C and C++. Why do you need that? Why not to use functors?
More on functors, for example, here: http://www.cprogramming.com/tutorial/functors-function-objects-in-c++.html