Export (0) Print
Expand All
Expand Minimize

Compiler Error C2896

'function1' : cannot use function template 'function2' as argument

A function template cannot be an argument to another function template.

The following sample generates C2896:

// C2896.cpp
template<class T1, class T2> void f1(void(*)(T1, T2));
template<class T1, class T2> void f2(T1, T2);

int main() {
   f1(f2);   // C2896
}

C2896 can also occur when you use generics:

// C2896b.cpp
// compile with: /clr
generic<class T1> void gf1(T1){}
generic<class T1> void gf2(T1){}

int main() {
   gf1(gf2);   // C2896
   gf1(1);   // OK
}
Show:
© 2015 Microsoft