Thursday, June 21, 2012

Using a function of a superclass as template param is not allowed

struct A{
  void f(){}

struct B:public A{

template<typename C,void (C::*f)()>
struct Call{

  void operator()(C* c){

int main(){
  B b;
  Call<B,&B::f> a;


====Compiler output===
 error: could not convert template argument ‘&A::f’ to ‘void (B::*)()’


 void (B::*f)()=&B::f; works

No comments:

Post a Comment