Event.h
class Event {
template <typename T, void(T::*MF)(int)>
void temp_callback(int r){
}
template <typename T, void(T::*MF)(int)>
void temp_add(T *obj, int a){
obj->testobj3<T, MF>(obj, a); // throws error here
temp_callback<T, MF>(a);
}
}
Test.h
class Test{
void testobj(int r);
void testobj2();
template <typename T, void(T::*MF)(int)>
void testobj3(T *obj, int a){
}
}
Test.cc
void Test::testobj2(){
Event eve;
eve.temp_add<Test, &Test::testobj>(this, 1);
}
int main() {
Test t;
t.testobj2();
}
Above code throws an error saying "error: expected primary-expression before ‘,’ token". If I instead define a non-template function for testobj3 and call obj->testobj3 (Where it's throwing error), it works fine. Not sure why the templated call would throw an error?
Thanks much for your time in advance!