Is it possible to pass a pointer to a function as an argument to a template without using typedef?
template<class PF>
class STC {
PF old;
PF& ptr;
public:
STC(PF pf, PF& p)
: old(*p), ptr(p)
{
p = pf;
}
~STC() {
ptr = old;
}
};
void foo() {}
void foo2() {}
int main() {
void (*fp)() = foo;
typedef void (*vfpv)();
STC<vfpv> s(foo2, fp);
}
source
share