Hello,
The following code doesn't compile using "Sun C++ 5.10 SunOS_sparc 2009/06/03" with the following error:
line 15: Error: Could not find a match for MyCallback<Param, Callee, Function>(Test*, int) needed in main()
However the same code compiles using g++ or "Sun C++ 5.12 SunOS_sparc Patch 148506-09 2013/02/21".
It seems to me that it is a compiler bug. Is there a workaround? Is there a patch for 5.10? Otherwise what is the minimal version of the compiler that fixes this bug?
Thank you, Petr
template<typename Param, class Callee, void (Callee::*Function)(Param)>
void MyCallback(Callee* callee, Param param) {
(callee->*Function)(param);
}
class Test {
public:
void test(int x) {
//std::cout << "test(" << x << ")" << std::endl;
}
};
int main() {
Test t;
MyCallback<int, Test, &Test::test>(&t, 1);
return 0;
}