struct A{
void f(){}
};
struct B:public A{
};
template<typename C,void (C::*f)()>
struct Call{
void operator()(C* c){
(c->*f)();
}
};
int main(){
B b;
Call<B,&B::f> a;
a(&b);
}
====Compiler output===
error: could not convert template argument ‘&A::f’ to ‘void (B::*)()’
~~~~~~~INSTEAD~~~~~~
void (B::*f)()=&B::f; works
No comments:
Post a Comment